这是我的代码
MysqlConn.Open()
command.Connection = MysqlConn
command.CommandText = CommandType.Text
command.CommandText = "INSERT INTO order VALUES (@1,@2,@3,@4,@5,@6,@7,@8)"
command.Parameters.AddWithValue("@1", rw.Cells(0).Value)
command.Parameters.AddWithValue("@2", rw.Cells(1).Value)
command.Parameters.AddWithValue("@3", rw.Cells(2).Value)
command.Parameters.AddWithValue("@4", rw.Cells(3).Value)
command.Parameters.AddWithValue("@5", Now())
command.Parameters.AddWithValue("@6", TextBox6.Text)
command.Parameters.AddWithValue("@7", TextBox7.Text)
command.Parameters.AddWithValue("@8", TextBox8.Text)
command.ExecuteNonQuery()
Next
MsgBox("done")
MysqlConn.Close()
command.Parameters.Clear()
我已经完成了“插入订单(names
,.....)值(@ 1,....)但仍然无效。我使用mysql
答案 0 :(得分:0)
Dim I As Integer
For I = 0 To Dgrd.Rows.Count - 2
Dim row As DataGridViewRow = Dgrd.Rows(I)
Dim SQLCON As New SqlConnection(MyDataBaseCon)
Dim CMD As SqlCommand
Dim S1 As DataGridViewTextBoxCell = row.Cells(1)
Dim S2 As DataGridViewTextBoxCell = row.Cells(2)
Dim S3 As DataGridViewTextBoxCell = row.Cells(3)
CMD = New SqlCommand("Insert Into order
(S1,S2,S3) Values (@S1,@S2,@S3)", SQLCON)
SQLCON.Open()
CMD.Parameters.Add(New SqlParameter("@S1", SqlDbType.Int)).Value = S1
CMD.Parameters.Add(New SqlParameter("@S2", SqlDbType.Int)).Value = S2
CMD.Parameters.Add(New SqlParameter("@S3", SqlDbType.NVarChar, 50)).Value = S3
CMD.ExecuteNonQuery()
SQLCON.Close()
Next
MsgBox("done")