المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حذف سطر من datagridview


eshrag.net
09-01-2010, 06:22 AM
لدي قاعدة بيانات و كونت بها Delete procedure نصه
ALTERproc [dbo].[Deleteitems](@MainLineID int)
as
begin
deletefrom dbo.Main_Line
where MainLineID=@MainLineID
end
و عند تطيقه علي برنامج vb.net 2005 كتبت كود الحذف هكذا فأين الخطا
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i AsInteger
Dim ta AsNew M_ListDataSetTableAdapters.Main_LineTableAdapter
Dim x As MsgBoxResult
x = MsgBox("Are you sure", MsgBoxStyle.YesNo, "Confirm")
If x = MsgBoxResult.Yes Then
For i = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(i).Cells(0).Value = TrueThen
ta.Deleteitems(DataGridView1.Rows(i).Cells(1).Valu e)
EndIf
Next
EndIf
EndSub