Evening All,
i am trying to input 72003 3131/1 from text from a text field into sql
as a string.
I have the following code but getting an error
Error while inserting record on table, incorrect syntax near '3131'.
the end user will be able to change this text to anything they like and still
the exe will run.
Private Sub line2add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles line2add.Click
Dim NewLongDesc As String
Dim RConv As String
Dim StkCodeV As String
RConv = Me.txtLine2Rcon.Text
NewLongDesc = Me.txtLongDesc.Text
StkCodeV = Me.txtStockCode.Text
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Try
con.ConnectionString = "Data Source=10.10.0.25;Initial Catalog=RConditions;Persist Security Info=True;User ID=mbish;Password=mbish"
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO LN2(Stkcode, LongDesc,RCon) VALUES(" & StkCodeV & "," & NewLongDesc & "," & RConv & ")"
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
Finally
con.Close()
End Try
End Sub
please help