Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql Parameters Problem
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00737516
Message ID:
00737518
Views:
21
Try Int32.Parse or whatever the VB equivalent is.

intFileNum = Int32.Parse(TeSearchFileNum.Text)

Or use the System.Convert method (which calls the Int32.Parse method anyway)

Dim newString As String = "123456789"
Dim MyInt As Integer = Convert.ToInt32(newString)


>Hi,
>
>Using .net, Windows Forms, Vb and the sql wizards...
>Trying to set sql parameters. I enter either a value or nothing into the TeSearchFileNum.Text TEXTBOX control field.
>
>I get the error message:
>An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
>Additional information: Cast from string " " to type 'Integer' is not valid.
>
> Dim intFileNum As Integer
> Dim intFileNum As Integer
> If TeSearchFileNum.Text Is Nothing Or TeSearchFileNum.Text Is "" Then
> intFileNum = 0
> Else
> intFileNum = CInt(TeSearchFileNum.Text)
> End If SqlDaListing.SelectCommand.Parameters("@FileNum").Value = intFileNum
>
>FileNum is an int field in the sql table.
>Does not seem to be comparing to nothing or "".
>
>Any suggestions?
>
>Thanks
>Roland
Previous
Reply
Map
View

Click here to load this message in the networking platform