19-07-15, 06:44 PM
الكود
مكان الخطا cmd.ExecuteNonQuery()
الخطا يقول
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: The INSERT INTO statement contains the following unknown field name: '@Ren_Date'. Make sure you have typed the name correctly, and try the operation again.
ما الحل يا اخواني ؟؟
كود :
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If i > DataGridView1.Rows.Count - 1 Then Exit For
Dim sql As String =
" INSERT INTO [Rent_Equipment] " &
" ( Cus_ID, Cus_Name, Cus_Private_Number, Equ_ID, Equ_Name, Equ_Quantity, Equ_Price, @Ren_Date ) " &
" VALUES " &
" ( @Cus_ID, @Cus_Name, @Cus_Private_Number, @Equ_ID, @Equ_Name, @Equ_Quantity, @Equ_Price, @Ren_Date ) "
Dim cmd As New OleDbCommand(sql, conn)
cmd.Parameters.AddWithValue("@Equ_ID", DataGridView1.Rows(i).Cells(0).Value)
cmd.Parameters.AddWithValue("@Equ_Name", DataGridView1.Rows(i).Cells(1).Value)
cmd.Parameters.AddWithValue("@Equ_Quantity", DataGridView1.Rows(i).Cells(2).Value)
cmd.Parameters.AddWithValue("@Cus_ID", ComboBox1.Text)
cmd.Parameters.AddWithValue("@Cus_Name", TextBox1.Text)
cmd.Parameters.AddWithValue("@Cus_Private_Number", TextBox2.Text)
cmd.Parameters.AddWithValue("@Equ_Price", TextBox4.Text)
cmd.Parameters.AddWithValue("@Ren_Date", DateTimePicker1.Value.Date)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
MessageBox.Show("We have been successfully Date", "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)
i += 1
Next iمكان الخطا cmd.ExecuteNonQuery()
الخطا يقول
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: The INSERT INTO statement contains the following unknown field name: '@Ren_Date'. Make sure you have typed the name correctly, and try the operation again.
ما الحل يا اخواني ؟؟