473,804 Members | 3,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding row to OLEDB Rowset does not add row to Access db

I have a project where the backend is Access. I have learned (slowly) to
use OLEDB to access my data. However, to save changes, I need to generate a
SQL statement. This seems clunky. I am used to MFC recordsets. The OleDB
system will let me add the row to the rowset, but then does nothing with it.
I have tried calling BeginEdit/EndEdit, AcceptChanges (from several
different classes), System.Data.Dat aTable.Rows.Add , and
System.Data.Dat aSet.Update. They appear to add the row to the OLEDB version
of the table, but until Access sees a new row, it is worthless.

For now, I am generating SQL Insert, Update, and Delete queries as needed.
However, that code is not reusable. Is there a better way? I hope so.
----------
Will Pittenger
E-Mail: mailto:will.pit tenger1 at gmail.com
All mail filtered by Qurb (www.qurb.com)
Nov 17 '05 #1
4 3075
Will,

While you are using OLEDB to access your Access data, you are not using
OLEDB when you are using the DataTable, DataSet, and other classes. The
provider you are using is OleDb (because you are using classes in the
System.Data.Ole Db namespace).

That being said, the dataset in .NET is a disconnected recordset,
meaning that it is populated with data, and no connection to the database is
retained. In order to update the dataset, you need to create an
OleDbDataAdapte r (which you did already because you selected the information
to fill the dataset) and set the InsertCommand, DeleteCommand, and
UpdateCommand properties to instances of OleDbCommand classes which
represent the insert, delete, and update statements. Then, pass your
changed recordset to the Update method on the adapter, and it will take care
of updating the back end.

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

"Will Pittenger" <se***********@ see.signature.n et> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I have a project where the backend is Access. I have learned (slowly) to
use OLEDB to access my data. However, to save changes, I need to generate
a SQL statement. This seems clunky. I am used to MFC recordsets. The
OleDB system will let me add the row to the rowset, but then does nothing
with it. I have tried calling BeginEdit/EndEdit, AcceptChanges (from
several different classes), System.Data.Dat aTable.Rows.Add , and
System.Data.Da taSet.Update. They appear to add the row to the OLEDB
version of the table, but until Access sees a new row, it is worthless.

For now, I am generating SQL Insert, Update, and Delete queries as needed.
However, that code is not reusable. Is there a better way? I hope so.
----------
Will Pittenger
E-Mail: mailto:will.pit tenger1 at gmail.com
All mail filtered by Qurb (www.qurb.com)

Nov 17 '05 #2
So, it still will not generate the Update, Delete, and Insert statements for
me like the MFC recordsets? With a simple table (rather than a join), I did
not even need to generate the Select statement using MFC. I miss that.
----------
Will Pittenger
E-Mail: mailto:will.pit tenger1 at gmail.com
All mail filtered by Qurb (www.qurb.com)
Nov 17 '05 #3
Hi Will,

A OleDbCommandBui lder will generate those statements for you :-

OleDbCommandBui lder myCB = new OleDbCommandBui lder(myDataAdap ter);

Cheers.

"Will Pittenger" wrote:
So, it still will not generate the Update, Delete, and Insert statements for
me like the MFC recordsets? With a simple table (rather than a join), I did
not even need to generate the Select statement using MFC. I miss that.
----------
Will Pittenger
E-Mail: mailto:will.pit tenger1 at gmail.com
All mail filtered by Qurb (www.qurb.com)

Nov 17 '05 #4
The problem is that MS assumed that the person coding, me, knows a lot about
OLEDB. I know little to nothing about OLEDB. MFC recordsets I understand.
OleDB on the other hand, appears designed to confuse programmers. Nothing
is strait forward.

The class you mentioned is just sitting out there. There is little to no
discussion about what to do with said class.
----------
Will Pittenger
E-Mail: mailto:will.pit tenger1 at gmail.com
All mail filtered by Qurb (www.qurb.com)
Nov 17 '05 #5

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

Similar topics

1
6746
by: Andrea Sansottera | last post by:
Hi fellows, I was wondering if in the Java API there's a way to easily map a disconnected RowSet to a JTable... I have looked at the doc but i did not found anything. What I want is simply do the follow: 1. Load: Database -> disconected Rowset -> automapping in a JTable 2. Editing of the data in the table/rowset
6
3469
by: Paul M. | last post by:
Hi, I am trying to add a dataset to a list box on an asp .net page, the query results in about 20 rows coming back when I run it in access but when I loop through the dataset adding each records field to the list box, the list box only shows the first one and no others. Anyone know whats going on? Thanks Paul Code ======================================
4
409
by: Manish Sawjiani | last post by:
Hi Experts, I am just into dot net and i want simple code for adding records into Access table (97) using oledb. There are no queries in the databases and there is only one table: Friends with the following fields: FriendID (AutoNumber) FirstName, LastName and DateOfBirth Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP Thanks all
2
2626
by: gigi | last post by:
I have a strange problem with an OleDB call to a stored procedure that returns a rowset. Only the first time I execute the query, after I restart SqlServer, my program crashes because the rowset is empty. All next calls (after restarting my program, of course) run successfully. The context is: 1) if I do not bind the output rowset, my program doesn't crash 2) If I run the call without the binding and then I run the call with
0
5032
by: Lewt | last post by:
I am aware of the 'hack the registry' approach. This is just not a safe way to accomplish this on a user's PC. I need to do this the right way. Is there anyone -perhaps from Microsoft - out there who can assist me on this? "Colin Stutley" wrote: > I now see your dilemma. > > Not sure of the appropiate API calls, but an alternative may be to simple > add the appropiate registry entries for the DSN. I would try; > 1) Export your...
12
3581
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new field with the type AutoNumber. I can then set this up as a key. Then if I go into the table I will see sequential numbers have been inserted into that field for me. Can I do this through VB.net I'd appreciate any help or alternative suggestions...
8
2559
by: Bonzol | last post by:
Hi there, VB 2003 1.1 Access Database, oledb, Windows Application I've been trying this for 3 days straight now and CANNOT get this to work, im about to go insane because it is soo simple. All I want to do is insert a new row ! I have 1 table 'People'
7
1790
by: Miro | last post by:
Im a VB Newbie so I hope I'm going about this in the right direction. I have a simple DB that has 1 Table called DBVersion and in that table the column is CurVersion ( String ) Im trying to connect to the db, and then add a record to the DBVersion table. Except I cant. I have 1 line that crashes and if i rem it out it works but nothing gets added.
1
2513
by: vbDavidC | last post by:
I am adding a new record to a table via a dataset/adapter. I have got the following to work for me but I am wondering if there is a better way to do this. I am having to have something in my DS before I can add records, since DS does not exist. I'd rather not have a SELECT since I really don't need any records in my dataset that I will be adding a new record to. Dim dsNewRow As DataRow
0
9587
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
10588
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
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
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...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
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.