Why can't I get the changes in my grid to update the data base?

Here's the code..............

Public Class frmAddChangeDelete
Inherits System.Windows.Forms.Form
Dim currpath As String = System.Environment.CurrentDirectory
Dim connService As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & currpath & "\ServiceCalls.mdb")
Private daCustomers
Private daCalls
Private daStatus

Private serviceDS As New DataSet

Private Sub frmAddChangeDelete_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim daCustomers As New System.Data.OleDb.OleDbDataAdapter("Select * from Customers", connService)
Dim daCalls As New System.Data.OleDb.OleDbDataAdapter("Select * from Calls", connService)
Dim daStatus As New System.Data.OleDb.OleDbDataAdapter("Select * from Status", connService)

serviceDS.Tables(0).TableName = "Customers"
DataGrid1.DataSource = serviceDS.Tables("Customers")

serviceDS.Tables(1).TableName = "Calls"
DataGrid2.DataSource = serviceDS.Tables("Calls")

serviceDS.Tables(2).TableName = "Status"
DataGrid3.DataSource = serviceDS.Tables("Status")

DataGrid1.SetDataBinding(serviceDS, "Customers")

End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

Dim command_builder As New System.Data.OleDb.OleDbCommandBuilder(daCustomers)

daCustomers.Update(serviceDS, "Customers")

Catch ex As Exception

End Try

End Sub
End Class


There is no "Currpath" string in VB.NET, Instead try to give complete location of ServiceCalls.mdb database under 'Data Source'.

The currPath statement is working though. My datagrids are getting populated from the database. I'll try you're suggestion though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.