ผมมีปัญหาที่ปุ่มลบข้อมูล พอกดแล้วมันก็เด้ง คำนี้ขึ้นมา Update requires a valid DeleteCommand when passed DataRow collection with deleted rows. ผมใช้ Vb2010 นะ
โค้ด
Private Sub Form34_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DatabaseFwDataSet.บ่อเสริม_30cm' table. You can move, or remove it, as needed.
Me.บ่อเสริม_30cmTableAdapter.Fill(Me.DatabaseFwDataSet.บ่อเสริม_30cm)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text) - Val(TextBox3.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
บอเสรม30cmBindingSource.AddNew()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
บอเสรม30cmBindingSource.EndEdit()
บ่อเสริม_30cmTableAdapter.Update(DatabaseFwDataSet.บ่อเสริม_30cm) บรรทัดนี้ครับ
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
บอเสรม30cmBindingSource.RemoveCurrent()
บอเสรม30cmBindingSource.EndEdit()
บ่อเสริม_30cmTableAdapter.Update(DatabaseFwDataSet.บ่อเสริม_30cm)
End Sub
End Class
Update requires a valid DeleteCommand when passed DataRow collection with deleted rows. แก้ยังไงครับ
โค้ด
Private Sub Form34_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DatabaseFwDataSet.บ่อเสริม_30cm' table. You can move, or remove it, as needed.
Me.บ่อเสริม_30cmTableAdapter.Fill(Me.DatabaseFwDataSet.บ่อเสริม_30cm)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text) - Val(TextBox3.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
บอเสรม30cmBindingSource.AddNew()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
บอเสรม30cmBindingSource.EndEdit()
บ่อเสริม_30cmTableAdapter.Update(DatabaseFwDataSet.บ่อเสริม_30cm) บรรทัดนี้ครับ
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
บอเสรม30cmBindingSource.RemoveCurrent()
บอเสรม30cmBindingSource.EndEdit()
บ่อเสริม_30cmTableAdapter.Update(DatabaseFwDataSet.บ่อเสริม_30cm)
End Sub
End Class