i am couldnt able to insert datagrid view manually entered data to mysql db with other control datas together into 1 table.
so i made 2 table and in 1 inserting all grid data in other rest still i m getting the same error:
" you have an error in your SQl syntax; check the manual that coressponds to your mysql server version for right syntax to use near '",",",",")' at line 1"
my code is
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New MySqlConnection
Dim mycommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Try
conn.ConnectionString = "server = localhost; database = abc; userid=root; password =root;"
conn.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Try
Dim Dr As New DataGridViewRow
mycommand.CommandText = "insert into q1 values('" & Lqno.Text & "' , '" & Tqcname.Text & " ',' " & Lqdate.Text & " ', '" & Tqaddress.Text & "','" & Tqsub.Text & "','" & Tsubtotal.Text & "','" & Tvat.Text & "','" & Tgtotal.Text & "')"
mycommand.CommandType = CommandType.Text
mycommand.Connection = conn
myAdapter.SelectCommand = mycommand
mycommand.ExecuteNonQuery()
For Each Dr In Quotdgv.Rows
Try
mycommand.CommandText = "insert into qd values(" & Dr.Cells(0).Value & ",'" & Dr.Cells(1).Value & "','" & Dr.Cells(2).Value & "','" & Dr.Cells(3).Value & "','" & Dr.Cells(4).Value & "','" & Dr.Cells(5).Value & "')"
mycommand.CommandType = CommandType.Text
mycommand.Connection = conn
myAdapter.SelectCommand = mycommand
mycommand.ExecuteNonQuery()
Catch ex As MySqlException
MsgBox(ex.ToString)
End Try
Next
Catch ex As MySqlException
MsgBox(ex.ToString)
End Try
End Sub