This is a trial page but i am not getting as to how i can pass integer type variable inputs in SQL 7.0 using asp.net
Here's my code. Hope somebody can help.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String
Dim b As Integer
b = 10
a = Request.QueryString("y")
TextBox1.Text = a
Dim str As String
str = " insert into abctrial values( '" + a + "' , b) "
cmd = New SqlCommand(str, conn)
cmd.ExecuteNonQuery()
conn.Close()
End Sub
The error i am getting is
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:
Line 59: TextBox1.Text = a
Line 60: Dim str As String
Line 61: str = " insert into abctrial values( '" + a + "' ," + b + ") "
Line 62: cmd = New SqlCommand(str, conn)
Line 63: cmd.ExecuteNonQuery()
Source File: D:\Inetpub\wwwroot\amglink_2006\AMGLINK_2006_Local \link\WebForm3.aspx.
vb Line: 61
Stack Trace:
[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.DoubleType. Parse(String Value, NumberFormatInfo NumberFormat) +165
Microsoft.VisualBasic.CompilerServices.DoubleType. FromString(String Value, NumberFormatInfo NumberFormat) +84
[InvalidCastException: Cast from string " insert into abctrial values( 's" to type 'Double' is not valid.]
Microsoft.VisualBasic.CompilerServices.DoubleType. FromString(String Value, NumberFormatInfo NumberFormat) +173
Microsoft.VisualBasic.CompilerServices.DoubleType. FromString(String Value) +7
link.WebForm3.Button1_Click(Object sender, EventArgs e) in D:\Inetpub\wwwroot\amglink_2006\AMGLINK_2006_Local \link\WebForm3.aspx.
vb:61
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0
Sonam