Hi all,
I can update using this code but the problem is that when I wanted to delete the whole rows using this code it code not. Could anyone help me?
Here is the code that I am using:
Dim myDA As OleDbDataAdapter
Dim myDataSet As DataSet
Private Sub ViewCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As OleDbConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = G:\MajorProjectFile\ProjectSample\database\User.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT CustID,custName,Address,Positions,CompanyName,Email,Telephone,Industry FROM Customer", con)
con.Open()
myDA = New OleDbDataAdapter(cmd)
'Automatically generates DeleteCommand,UpdateCommand and InsertCommand for DataAdapter object
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
myDataSet = New DataSet()
myDA.Fill(myDataSet, "Customer")
DataGridView1.DataSource = myDataSet.Tables("Customer").DefaultView
con.Close()
con = Nothing
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Validate()
Me.myDA.Update(Me.myDataSet.Tables("Customer"))
Me.myDataSet.AcceptChanges()
End Sub
Thanks
Regards
LiL_is