19-07-15, 11:14 PM
الكود تبعك يوجد به مشكلة بعد والمشكلة تقول ان :
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: ' Cus_ID'. Make sure you have typed the name correctly, and try the operation again.
هذا هو مكان الخطأ
cmd.ExecuteNonQuery()
الكود التي قمت بإضافته
Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")
conn.Open()
For Each row As DataGridViewRow In DataGridView1.Rows
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 ) "
Using cmd As New OleDbCommand(sql, conn)
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_ID", row.Cells(0).Value)
cmd.Parameters.AddWithValue("@Equ_Name", row.Cells(1).Value)
cmd.Parameters.AddWithValue("@Equ_Quantity", row.Cells(2).Value)
cmd.Parameters.AddWithValue("@Equ_Price", TextBox4.Text)
cmd.Parameters.AddWithValue("@Ren_Date", DateTimePicker1.Value.Date)
cmd.ExecuteNonQuery()
End Using
Next
conn.Close()
End Using
MessageBox.Show("We have been successfully Date", "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)
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: ' Cus_ID'. Make sure you have typed the name correctly, and try the operation again.
هذا هو مكان الخطأ
cmd.ExecuteNonQuery()
الكود التي قمت بإضافته
Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")
conn.Open()
For Each row As DataGridViewRow In DataGridView1.Rows
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 ) "
Using cmd As New OleDbCommand(sql, conn)
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_ID", row.Cells(0).Value)
cmd.Parameters.AddWithValue("@Equ_Name", row.Cells(1).Value)
cmd.Parameters.AddWithValue("@Equ_Quantity", row.Cells(2).Value)
cmd.Parameters.AddWithValue("@Equ_Price", TextBox4.Text)
cmd.Parameters.AddWithValue("@Ren_Date", DateTimePicker1.Value.Date)
cmd.ExecuteNonQuery()
End Using
Next
conn.Close()
End Using
MessageBox.Show("We have been successfully Date", "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)

