Dim con As New SqlClient.SqlConnection("data source=.; initial catalog= library;integrated security=true")
Dim ds As New DataSet
Dim da As New SqlClient.SqlDataAdapter
هذا كود فتح الاتصال في المنطقة العامة
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
da.SelectCommand = New SqlClient.SqlCommand
da.SelectCommand.Connection = con
da.SelectCommand.CommandText = "select * from br"
da.Fill(ds, "br")
DataGrid1.DataSource = ds.Tables("br")
هذا الكود في منطقة load form
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Integer
Dim c As New SqlClient.SqlCommandBuilder(da)
i = DataGrid1.CurrentRowIndex
ds.Tables("br").Rows(i).Delete()
da.Update(ds.Tables("br"))
MsgBox("delet is done")هذا كود الحذف
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
لما اضغط زر الحذف تطلع هذة الرسالة
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information.
مع ان استعمل هذة الطريقة على فورم ثاني شغالة
وشكرا