VB.NET "Text" to SQL "Text"?


K

Kivak Wolf

Hey everyone,

I have a textbox in my web page that is going to be used to enter an
E-mail into (just plain text, no HTML). Now, this will interact with a
SQL database where the contents of the textbox are sent from the SQL
database to the textbox, then the user edits it, and then the text
inside the textbox is sent back to the SQL database.

I did it the same way as if i had used a VarChar instead of a type
"text" variable in the SQL database, except I changed it to type "text"
on both the SQL database and in the parameters for the SQL statement in
ASP.NET. But for some reason, it still says there is a problem with the
formatting.

This is the error I get:

(Mind you this is in ASP.NET 2.0 so please answer in ASP.NET 2.0 so it
works. =D)
----------------------------------------------------------------------------

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a
correct format.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
+2637199
System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info) +102
System.String.System.IConvertible.ToInt32(IFormatProvider provider)
+43
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +293
System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand
command, ParameterCollection reference, IDictionary parameters,
IDictionary exclusionList, String oldValuesParameterFormatString) +609

System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +363
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +1144
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +643
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +134

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+180
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5670
 
Ad

Advertisements

R

Random

We'll need more information than this. Can you give us an example of the
text that is giving you the problem? Are you using a dynamic SQL statement
to do the insert, or a stored procedure?

Kivak Wolf said:
Hey everyone,

I have a textbox in my web page that is going to be used to enter an
E-mail into (just plain text, no HTML). Now, this will interact with a
SQL database where the contents of the textbox are sent from the SQL
database to the textbox, then the user edits it, and then the text
inside the textbox is sent back to the SQL database.

I did it the same way as if i had used a VarChar instead of a type
"text" variable in the SQL database, except I changed it to type "text"
on both the SQL database and in the parameters for the SQL statement in
ASP.NET. But for some reason, it still says there is a problem with the
formatting.

This is the error I get:

(Mind you this is in ASP.NET 2.0 so please answer in ASP.NET 2.0 so it
works. =D)
----------------------------------------------------------------------------

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a
correct format.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
+2637199
System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info) +102
System.String.System.IConvertible.ToInt32(IFormatProvider provider)
+43
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +293
System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand
command, ParameterCollection reference, IDictionary parameters,
IDictionary exclusionList, String oldValuesParameterFormatString) +609

System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +363
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +1144
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +643
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +134

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+180
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5670
 
K

Kivak Wolf

Yey! Located the problem... but it seems that I can't do much about it.
=( In the HTML tag called "<UpdateParameters>" i have my parameters for
updating my database (duh). Problem is this, the parameter that i want
to be type "text" cannot be type "text". The closet one is type
"String". WHY!? =(
 
K

Kivak Wolf

Ok, it seems that the problem was not that it was trying to convert it
to type "text", the error was misleading. The real cause was that it
was trying to assign a VB.NET Null into a SQL database. Now, I tried
the inbuilt command that supposedly would convert it for you, however,
I have heard from many sources that this command is NOT functional. It
will be functional (hopfully) when the release comes out. So now I have
a new problem, how do I fix that? I am going to have Null values (or
empy strings) in my fields, but I need to assign them into the SQL
database.

Does anyone know how to do this?

(ASP.NET 2.0)
 
P

Patrice

For now you could perhaps have them as empty strings and set them to null
server side.

(As a side note my personal preference is to use empty strings instead of
NULL unless I have really a field whose value is really "unknown" instead of
just "blank").
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top