try
Dim da As String = "+100acs+"
Dim con As SqlConnection = New SqlConnection("Data Source=RAHUL-034890AF0\SERVER2005;Initial Catalog=user_accounts; Integrated Security =True")
Dim command As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand("Insert into sales_details (bill_number,product_id,quantity,rate,amount) VALUES ('" + da + " ','" + Ddpproducts.SelectedItem.ToString + " ','" + Textquant.Text + "','" + Ddpproducts.SelectedValue + "','" + 2306 + "')", con)
command.BeginExecuteNonQuery()
con.Close()
Catch [x] As Exception
Txterror.text = x
End Try
I get the following error in my error textbox:
System.InvalidCastException: Conversion from string "Insert into sales_details (bill_" to type 'Double' is not valid. ---> System.FormatException: Input string was not in a correct format. at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) --- End of inner exception stack trace --- at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value) at _Default.btnadd_Click(Object sender, EventArgs e) in D:\sms_new\salesbill.aspx.vb:line 71
My bill number field is nvarchar(10) in sql2005 and even if I replace da with numbers or alphabets (eg– 123, abc)I still get and error.