W
Warex
I am banging my head agaisnt the wall, how do I add a new row and edit a
row?
Below is the code I am trying to use, it keeps throwing an exception abount
no insert command. Any ideas about this?
thnks
Dim mDBN As String = "C:\BNM.MDB"
Dim cCON As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mDBN
& ";Persist Security Info = False"
Dim mSQL As String = "SELECT * FROM Numbers"
Dim cn As New OleDb.OleDbConnection(cCON)
Dim DA As New OleDb.OleDbDataAdapter(mSQL, cn)
Dim DS As New DataSet
DA.FillSchema(DS, SchemaType.Source, "Numbers")
DA.Fill(DS, "Numbers")
Dim CBA As New OleDb.OleDbCommandBuilder(DA)
DA.UpdateCommand = CBA.GetUpdateCommand
Dim DT As New DataTable
DT = DS.Tables("Numbers")
Dim DR As DataRow
DR = DS.Tables("Numbers").NewRow
DR.BeginEdit()
DR("Number") = "OKAY DOO"
DR.EndEdit()
DS.Tables("Numbers").Rows.Add(DR)
DA.Update(DS, "Numbers")
row?
Below is the code I am trying to use, it keeps throwing an exception abount
no insert command. Any ideas about this?
thnks
Dim mDBN As String = "C:\BNM.MDB"
Dim cCON As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mDBN
& ";Persist Security Info = False"
Dim mSQL As String = "SELECT * FROM Numbers"
Dim cn As New OleDb.OleDbConnection(cCON)
Dim DA As New OleDb.OleDbDataAdapter(mSQL, cn)
Dim DS As New DataSet
DA.FillSchema(DS, SchemaType.Source, "Numbers")
DA.Fill(DS, "Numbers")
Dim CBA As New OleDb.OleDbCommandBuilder(DA)
DA.UpdateCommand = CBA.GetUpdateCommand
Dim DT As New DataTable
DT = DS.Tables("Numbers")
Dim DR As DataRow
DR = DS.Tables("Numbers").NewRow
DR.BeginEdit()
DR("Number") = "OKAY DOO"
DR.EndEdit()
DS.Tables("Numbers").Rows.Add(DR)
DA.Update(DS, "Numbers")