私人小組btnSave_ClientOrderStatus_Click(BYVAL發件人爲System.Object的,BYVALË作爲System.EventArgs)保存ListView項把手btnSave_ClientOrderStatus.Click mysqlconn =新的MySqlConnection mysqlconn.ConnectionString = serverstring具有多個行和列,以MySQL數據庫
Try
mysqlconn.Open()
Dim query As String = "insert into isad.invoice_table(Invoice, Clientnumber, Firstname, Lastname, ProductID, Name, Price, Qty, Description, Total, DateCreated) values "
command = New MySqlCommand(query, mysqlconn)
For i = 0 To ListView1.Items.Count - 1
query &= "('" & txtInvoice_ClientOrderStatus.Text & "','" & txtClientNumber_ClientOrderStatus.Text.Replace("'", "\'") & "','" & txtFname_ClientOrderStatus.Text.Replace("'", "\'") & _
"', '" & txtLname_ClientOrderStatus.Text.Replace("'", "\'") & "', @ProductID" & i.ToString & ", @Name" & i.ToString & ", @Price" & i.ToString & _
", @Quantity" & i.ToString & ", @Description" & i.ToString & ", '" & txtTotal_ClientOrderStatus.Text & "',now())"
command.Parameters.AddWithValue("@ProductID" & i.ToString, ListView1.Items(i).Text)
command.Parameters.AddWithValue("@Name" & i.ToString, ListView1.Items(i).SubItems(1).Text)
command.Parameters.AddWithValue("@Price" & i.ToString, ListView1.Items(i).SubItems(2).Text)
command.Parameters.AddWithValue("@Quantity" & i.ToString, ListView1.Items(i).SubItems(3).Text)
command.Parameters.AddWithValue("@Description" & i.ToString, ListView1.Items(i).SubItems(4).Text)
query &= ", "
Next
query = query.Substring(0, query.Length - 2)
READER = command.ExecuteReader
SBP2.Text = "Status : Client invoice has been created"
MsgBox("Saving Client Order Succeed", vbInformation, "Done")
mysqlconn.Close()
autoincrement_ClientOrderStatus()
cleartext_ClientOrderStatus()
btnSave_ClientOrderStatus.Enabled = False
btnAdd_ClientOrderStatus.Text = "Add Transaction"
READER.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
mysqlconn.Close()
Finally
mysqlconn.Dispose()
End Try
End Sub
heres my project image, maybe it can help you genospos
Here's the error when i click save
你有問題嗎? – Strawberry