I am trying to insert values to a table in sql.I get the following error : Incorrect syntax near keyword 'values'.
I am using sql server 2008 r2.Following is my code.
If ProductTypeComboBox.Text = "REPAIR(INHOUSE)" Then
Using sqlcon As New SqlConnection(My.Settings.Hardware_DatabaseConnectionString)
' Dim sqlcon As New SqlConnection(My.Settings.Hardware_DatabaseConnectionString)
sqlcon.Open()
Dim sqlCmd As New SqlCommand("insert into Product_Table([Prd_Sr_Key_No],[Prd_Name],[Prd_Brand],[Prd_Type],[Prd_Detail],[Dte_Stck_In],[Brght_By],[Note],[Prd_Data_Crtd_By],[Prd_Data_Crtd_Date] Values(@srkeyno,@prdname,@prdbrand,@prdtype,@prddetail,@dtestckin,@brghtby,@note,@prddatacrtdby,@prddatacrtddate)", sqlcon)
sqlCmd.Parameters.AddWithValue("@srkeyno", Trim(SrKeyNoTextBox.Text))
sqlCmd.Parameters.AddWithValue("@prdname", Trim(ProductNameTextBox.Text))
sqlCmd.Parameters.AddWithValue("@prdbrand", BrandNameComboBox.Text)
sqlCmd.Parameters.AddWithValue("@prdtype", ProductTypeComboBox.Text)
sqlCmd.Parameters.AddWithValue("@prddetail", DetailRichTextBox.Text)
sqlCmd.Parameters.AddWithValue("@dtestckin", ddComboBox.Text + "/" + mmComboBox.Text + "/" + yyyyComboBox.Text)
sqlCmd.Parameters.AddWithValue("@brghtby", Trim(BroughtByTextBox.Text))
sqlCmd.Parameters.AddWithValue("@note", NoteRichTextBox.Text)
sqlCmd.Parameters.AddWithValue("@prddatacrtdby", Trim(CreatedByProdTextBox.Text))
sqlCmd.Parameters.AddWithValue("@prddatacrtddte", CreatedDateProdddComboBox.Text + "/" + CreatedDateProdmmComboBox.Text + "/" + CreatedDateProdyyComboBox.Text)
sqlCmd.ExecuteNonQuery()
MsgBox("Data added successfully")
End Using
Else
MsgBox("Input is other than REPAIR(INHOUSE)")
End If

New Topic/Question
Reply



MultiQuote






|