By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

Insert into MS-Access table does not work

P: n/a
Hi all

I don't understand why the following sample won't work.

I added a tableadapter with drag and drop from the datasource which is a
MS-Access DB and try to insert a record. The record is in the dataset
but never gets inserted in the access db.
Me.Tabelle1TableAdapter.Fill(Me.Db6DataSet.Tabelle 1)
Dim drnew As DataRow
drnew = Db6DataSet.Tabelle1.NewRow
drnew("Testfeld") = "MyTestStringToInsert"
Db6DataSet.Tabelle1.Rows.Add(drnew)
Tabelle1TableAdapter.Update(Db6DataSet.Tabelle1)
Regards

Manfred

Mar 25 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Manfred wrote:
Hi all

I don't understand why the following sample won't work.

I added a tableadapter with drag and drop from the datasource which is a
MS-Access DB and try to insert a record. The record is in the dataset
but never gets inserted in the access db.
Me.Tabelle1TableAdapter.Fill(Me.Db6DataSet.Tabelle 1)
Dim drnew As DataRow
drnew = Db6DataSet.Tabelle1.NewRow
drnew("Testfeld") = "MyTestStringToInsert"
Db6DataSet.Tabelle1.Rows.Add(drnew)
Tabelle1TableAdapter.Update(Db6DataSet.Tabelle1)
Regards

Manfred ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hello Manfred,my name is Eswar and i am working as a programmer in
dotnet.
Add a 'CommandBuilder' object of connection type you have used. As
dim cb as new OledbCommandBuilder(Me.Tabelle1TableAdapter) and

Try this code.
Me.Tabelle1TableAdapter.Fill(Me.Db6DataSet.Tabelle 1)
Dim drnew As DataRow
drnew = Db6DataSet.Tabelle1.NewRow
drnew("Testfeld") = "MyTestStringToInsert"
Db6DataSet.Tabelle1.Rows.Add(drnew)
Me.Tabelel1TableAdapter.InsertCommand=cb.GetInsert Command() ( I added this line)
Tabelle1TableAdapter.Update(Db6DataSet.Tabelle1)


Note: After doing any modification you have to get the command of that
type by using CommandBuilder object and then call the "Update()"
command of table adapter.
Have a nice day

Mar 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.