473,656 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OleDbDataAdapte r Update Question

bob
Hi.. I'm making a OleDb connection to a access database.. I can fill
the dataset
fine and view the data, but when I add a new row and try to update the
db I get this error. Any help would be appreciated..

Error: An unhandled exception of type
"System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll

This error is from the following line:

thisAdapter.Upd ate(thisDataSet , "tCompany") ;

Here's the code i'm using...
--------------------------------------------------------------------------------
OleDbConnection thisConnection = new
OleDbConnection (@"Provider=Mic rosoft.Jet.OLED B.4.0;Data
Source=C:\devel \csharp\company \db\company.mdb ");

OleDbDataAdapte r thisAdapter = new OleDbDataAdapte r("SELECT * FROM
tCompany", thisConnection) ;

DataSet thisDataSet = new DataSet();

thisAdapter.Fil l(thisDataSet, "tCompany") ;

DataRow thisRow=thisDat aSet.Tables["tCompany"].NewRow();
thisRow["name"]="some name";
thisRow["street"]="some street";
thisRow["city"]="some city";
thisRow["state"]="some state";
thisDataSet.Tab les["tCompany"].Rows.Add(thisR ow);

OleDbCommandBui lder thisBuilder = new
OleDbCommandBui lder(thisAdapte r);
thisAdapter.Upd ate(thisDataSet , "tCompany") ;

Thanks,

John Underwood
Nov 15 '05 #1
1 3732
Either the connection is closed. Or an error occured during opening the connection. Try opening the connection to verify that first

Nov 15 '05 #2

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

Similar topics

2
3813
by: Son Ha | last post by:
I want to copy some record from a Access database to another Access DB. My code as follow but not working. The destAdapter.Update() return 0 record affected. Tell me what's wrong in my code? public void CopyDataSet(int start, int end) { OleDbDataAdapter sourceAdapter = new OleDbDataAdapter("SELECT * FROM " + "WHERE ID > " + (start - 1).ToString() + " AND .id < " + (end + 1).ToString(), connectionString
1
5082
by: Bennett Haselton | last post by:
Suppose I add a new row to a table in a dataset, and then I use an OleDbDataAdapter to add that new row to a SQL Server database using OleDbDataAdapter.Update(), as in the following code: dsLocalDataSet.user_postRow newRow = dsLocalDataSet1.user_post.Newuser_postRow(); newRow.post_text = this.lblHiddenMessageStorage.Text; newRow.post_datetime = System.DateTime.Now; dsLocalDataSet1.user_post.Adduser_postRow(newRow);...
0
5809
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
1
4767
by: RML | last post by:
Hi everyone, I am using VB.NET 2003 and an OleDBDataAdapter to update an Access table's DateTime field. The field's format is set to "General Date" (ie: 11/24/2004 8:00:00 AM). The problem is the field ends up with only a date, with no time component. In my project... I added an OleDBDataAdapter using the wizzard to my form. I generated the DataSet and added the desired table. I verified the field type in the
5
3686
by: Al | last post by:
Hi, I need to update tables in access 97. The table names have spaces (not my choice). My update fails even though I use the OleDbCommandBuilder. Here is a code I am using myDataAdapter = New OleDbDataAdapter myDataAdapter.SelectCommand = New OleDbCommand("Select * from ", MyConnection) Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(PatientsBillingDataAdapter)
6
14903
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I would like to write the new ControlDate or Version into the database. First i update the dataset, then i create a Insertcommand and call the update-methode. All datas are in the database, but.... 1.) If I only use the InsertCommand, without...
6
1855
by: tom c | last post by:
I create 2 data OleDbDataAdapters, one with the wizard, and one in code. I know the adapter created in code is OK because I use it to fill a data table. However, when I try to use the same SQL insert statement in the two adapters, the adapter created with the wizard works fine, but the adapter created in code gives me an error "Object reference not set to an instance of an object". The code is below. What am I doing wrong? ...
2
2924
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 draging Table1 to Form2. The select command works fine, but when I change the data and call update command I get a syntax error: System.Data.OleDb.OleDbException was unhandled ErrorCode=-2147217900 Message="Syntax error in UPDATE statement."...
6
1675
by: baldrick | last post by:
Hello, I am trying to plonk the entire contents of a dBase file into an Access table. I have scanned the dBase fields and created an empty Access table with the same field formats. I have also created oledb connections to both data sources. Below is my attempt at achieving this, which doesn't work. I've
0
8382
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.