HOME > .NET Framework > Forum > ช่วยดูโค๊ดหน่อยค่ะ Parameterized Query '(@Companyname nvarchar(4000),@ContactName nvarchar(4000),@Contac' expects parameter @Companyname, which was not supplied.
ช่วยดูโค๊ดหน่อยค่ะ Parameterized Query '(@Companyname nvarchar(4000),@ContactName nvarchar(4000),@Contac' expects parameter @Companyname, which was not supplied.
Dim sql As String = ""
sql = " Update Customers SET Companyname=@Companyname,ContactName=@ContactName,ContactTitle=@ContactTitle,Address=@Address,City=@City,Region=@Region,PostalCode=@PostalCode,Country=@Country,Phone=@Phone,Fax=@Fax WHERE CustomerID=@CustomerID"
Cmd = New SqlCommand(sql, mySQLConn)
For r As Integer = 0 To DataGridView2.RowCount - 1
With Cmd
.Parameters.AddWithValue("Companyname", CStr(DataGridView2.Rows(r).Cells(1).Value))
.Parameters.AddWithValue("ContactName", CStr(DataGridView2.Rows(r).Cells(2).Value))
.Parameters.AddWithValue("ContactTitle", CStr(DataGridView2.Rows(r).Cells(3).Value))
.Parameters.AddWithValue("Address", CStr(DataGridView2.Rows(r).Cells(4).Value))
.Parameters.AddWithValue("City", CStr(DataGridView2.Rows(r).Cells(5).Value))
.Parameters.AddWithValue("Region", DataGridView2.Rows(r).Cells(6).Value)
.Parameters.AddWithValue("PostalCode", CStr(DataGridView2.Rows(r).Cells(7).Value))
.Parameters.AddWithValue("Country", CStr(DataGridView2.Rows(r).Cells(8).Value))
.Parameters.AddWithValue("Phone", CStr(DataGridView2.Rows(r).Cells(9).Value))
.Parameters.AddWithValue("Fax", CStr(DataGridView2.Rows(r).Cells(10).Value))
.Parameters.AddWithValue("CustomerID", CStr(DataGridView2.Rows(r).Cells(0).Value))
End With
ConnectDB()
Cmd.ExecuteNonQuery()
Cmd.Parameters.Clear()
Next
MsgBox("Successfully")
mySQLConn.Close()
เมื่อรันแล้วเกิดเออเรอ
Parameterized Query '(@Companyname nvarchar(4000),@ContactName nvarchar(4000),@Contac' expects parameter @Companyname, which was not supplied.