473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with OleDb

Hi,

OleDbConnection m_cnADONewConnection = new OleDbConnection();
OleDbDataAdapter m_daDataAdapter = new OleDbDataAdapter();
DataTable m_dtBackups = new DataTable();

// Connect:

string path = Application.StartupPath + @"\";
m_cnADONewConnection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "backup.mdb";
m_daDataAdapter =
new OleDbDataAdapter("Select * From backups",m_cnADONewConnection);
OleDbCommandBuilder m_cbCommandBuilder = new
OleDbCommandBuilder(m_daDataAdapter);
m_daDataAdapter.Fill(m_dtBackups);

// trying to update:

for (int i=0; i < m_dtBackups.Rows.Count; i++)
{
m_dtBackups.Rows[i]["name"]= "test!";

// Problem here:
m_daDataAdapter.Update(m_dtBackups);

}

How correctly to update?
Nov 17 '05 #1
2 1104
Kostya,

You don't have to pass the table to the data adapter for each row.
Rather, in the table, you make your changes, and call Update once. The
Update method will cycle through the rows in the table that have changes in
them, and then make the appropriate changes.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kostya Ergin" <ko****@erginsoft.com> wrote in message
news:eH**************@TK2MSFTNGP15.phx.gbl...
Hi,

OleDbConnection m_cnADONewConnection = new OleDbConnection();
OleDbDataAdapter m_daDataAdapter = new OleDbDataAdapter();
DataTable m_dtBackups = new DataTable();

// Connect:

string path = Application.StartupPath + @"\";
m_cnADONewConnection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "backup.mdb";
m_daDataAdapter =
new OleDbDataAdapter("Select * From backups",m_cnADONewConnection);
OleDbCommandBuilder m_cbCommandBuilder = new
OleDbCommandBuilder(m_daDataAdapter);
m_daDataAdapter.Fill(m_dtBackups);

// trying to update:

for (int i=0; i < m_dtBackups.Rows.Count; i++)
{
m_dtBackups.Rows[i]["name"]= "test!";

// Problem here:
m_daDataAdapter.Update(m_dtBackups);

}

How correctly to update?

Nov 17 '05 #2
Hi Nicholas!

Thanks for tip. I found solution - database need field with primary key.

Amusing C# :)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:On**************@tk2msftngp13.phx.gbl...
Kostya,

You don't have to pass the table to the data adapter for each row.
Rather, in the table, you make your changes, and call Update once. The
Update method will cycle through the rows in the table that have changes in them, and then make the appropriate changes.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
0
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and deletion...
2
by: explode | last post by:
I made nova oledbdataadapter select update insert and delete command and connection veza. dataset is Studenti1data, I made it by the new data source wizard,and made datagridview and bindingsource...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.