我正在尝试将这些值插入ms数据库,但出现数据不匹配错误
这是代码
If DbConnect() Then
Dim SQLCmd As New OleDbCommand
Dim dateafterconversion As String = datcurrentdate.Value.ToString("MM/dd/yyyy")
Dim dateafterconversion2 As String = datDuedate.Value.ToString("MM/dd/yyyy")
If CurrentRentalID = -1 Then
With SQLCmd
.Connection = cn
.CommandText = "Insert into Tbl_Rental(CustomerID, StaffID, DateOfHire, DateOfReturn, Noofdays, Customer_firstname, Customer_lastname)"
.CommandText &= " Values (@CustomerID, @StaffID, @DateOfHire, @DateOfReturn, @Noofdays, @Customer_firstname, @Customer_lastname)"
.Parameters.AddWithValue("@CustomerID", txt_Customerid_Rental.Text)
.Parameters.AddWithValue("@StaffID", txtStaffID.Text)
.Parameters.AddWithValue("@DateOfHire", dateafterconversion)
.Parameters.AddWithValue("@DateOfReturn", dateafterconversion2)
.Parameters.AddWithValue("@Customer_firstname", txtfirstname_rental.Text)
.Parameters.AddWithValue("@Customer_lastname", txtlastname_rental.Text)
.Parameters.AddWithValue("@Noofdays", days)
.ExecuteNonQuery()
.CommandText = "Select @@Identity"
CurrentRentalID = .ExecuteScalar
txtOrderID.Text = CurrentRentalID
我认为问题出在Customer_firstname和Customer_lastname的位置上。我已经在数据库中检查了它们的拼写,并且它们匹配,所以我不太清楚问题出在哪里
任何帮助将不胜感激 谢谢