Ryobi
Registered User.
- Local time
- Today, 06:32
- Joined
- Mar 5, 2012
- Messages
- 49
Hello,
I am new to VB net and connections. I am trying to save data from an Ms Access table using a table adapter. Everything works fine, except that I can save changes to the data. This is what I have:
MYConn = New OleDbConnection(StrConn)
Dim Sql As String = "Select * From Locations"
cmd = New OleDbCommand(Sql, MYConn)
Try
MYConn.Open()
Dim da As New OleDb.OleDbDataAdapter(Sql, MYConn)
Dim dt As New DataTable
da.Fill(dt)
BindingSource1.DataSource = dt
BindingNavigator1.BindingSource = BindingSource1
TxTLocCode.DataBindings.Add(New Binding("Text", BindingSource1, "Loc-Code"))
TxtLocation.DataBindings.Add(New Binding("Text", BindingSource1, "Location"))
MYConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
I can go through the records but any changes I make are not saved. I need know I need something like Bindingsource1.Save( Table.Fields) or Bindingsource1.Update (Table.Fields) in a button to press to save the data. Do I need to create a dataset to save it or there something wrong with my bindings ? Any help would be appreciated.
I am new to VB net and connections. I am trying to save data from an Ms Access table using a table adapter. Everything works fine, except that I can save changes to the data. This is what I have:
MYConn = New OleDbConnection(StrConn)
Dim Sql As String = "Select * From Locations"
cmd = New OleDbCommand(Sql, MYConn)
Try
MYConn.Open()
Dim da As New OleDb.OleDbDataAdapter(Sql, MYConn)
Dim dt As New DataTable
da.Fill(dt)
BindingSource1.DataSource = dt
BindingNavigator1.BindingSource = BindingSource1
TxTLocCode.DataBindings.Add(New Binding("Text", BindingSource1, "Loc-Code"))
TxtLocation.DataBindings.Add(New Binding("Text", BindingSource1, "Location"))
MYConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
I can go through the records but any changes I make are not saved. I need know I need something like Bindingsource1.Save( Table.Fields) or Bindingsource1.Update (Table.Fields) in a button to press to save the data. Do I need to create a dataset to save it or there something wrong with my bindings ? Any help would be appreciated.