raha1815
جمعه 03 مهر 1388, 13:36 عصر
سلام
من يه برنامه نوشتم با ديتابيس sqlserver2005 وقتي ميخواهم يك ركورد از ديتا بيس با استفاده از datagridview را DELETE كنم پيغام زير مياد .
Update requires the UpdateCommand to have a connection . the connection property of the deletecommand has not been initialized.
سورس برنامه هم ابنه البته قسمت delete
result = MsgBox("? آيا مي خواهيد اطلاعات حذف شود", MsgBoxStyle.YesNo, "Warning")
If result = MsgBoxResult.Yes Then
Dim IndexRow AsInteger
If IndexRow <> -1 Then
Try
IndexRow = BindingContext(Me.P5DataSet1,p5index").Position
P5DataSet1.p5index(IndexRow).Delete()
SqlDataAdapter1.Update(P5DataSet1.p5index)
P5DataSet1.p5index.Clear()
SqlDataAdapter1.Fill(P5DataSet1.p5index)
Catch ex As Exception
MsgBox(ex.Message)
EndTry
ممنون ميشم كمكم كنيد .
من يه برنامه نوشتم با ديتابيس sqlserver2005 وقتي ميخواهم يك ركورد از ديتا بيس با استفاده از datagridview را DELETE كنم پيغام زير مياد .
Update requires the UpdateCommand to have a connection . the connection property of the deletecommand has not been initialized.
سورس برنامه هم ابنه البته قسمت delete
result = MsgBox("? آيا مي خواهيد اطلاعات حذف شود", MsgBoxStyle.YesNo, "Warning")
If result = MsgBoxResult.Yes Then
Dim IndexRow AsInteger
If IndexRow <> -1 Then
Try
IndexRow = BindingContext(Me.P5DataSet1,p5index").Position
P5DataSet1.p5index(IndexRow).Delete()
SqlDataAdapter1.Update(P5DataSet1.p5index)
P5DataSet1.p5index.Clear()
SqlDataAdapter1.Fill(P5DataSet1.p5index)
Catch ex As Exception
MsgBox(ex.Message)
EndTry
ممنون ميشم كمكم كنيد .