syntax error in insert into statement
-
this is the msg that show when iam trying to apply this code
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String f1 = "#" & DateTimePicker1.Value & "#," f2 = "'" & ComboBox1.Text & "'," f3 = "'" & ComboBox2.Text & "'," f4 = "'" & TextBox1.Text & "'," f5 = "'" & TextBox2.Text & "'," f6 = "'" & TextBox3.Text & "'," f7 = "'" & TextBox4.Text & "'," f8 = "'" & Label10.Text & "'" s = "insert into sale" s = s & " (dte,op,nos,cost,coms,nii,npp)values " s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" cmd.CommandText = s cmd.ExecuteNonQuery() MsgBox("Saved succssefuly")
any suggestion ? plz help urgent -
this is the msg that show when iam trying to apply this code
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String f1 = "#" & DateTimePicker1.Value & "#," f2 = "'" & ComboBox1.Text & "'," f3 = "'" & ComboBox2.Text & "'," f4 = "'" & TextBox1.Text & "'," f5 = "'" & TextBox2.Text & "'," f6 = "'" & TextBox3.Text & "'," f7 = "'" & TextBox4.Text & "'," f8 = "'" & Label10.Text & "'" s = "insert into sale" s = s & " (dte,op,nos,cost,coms,nii,npp)values " s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" cmd.CommandText = s cmd.ExecuteNonQuery() MsgBox("Saved succssefuly")
any suggestion ? plz help urgentdte column looks datetime datatype
magedhv wrote:
s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"
change the query to s = s & "('" & f1 & "'," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" so that the date is incloded in single quotes
Regards KP