473,804 Members | 4,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I hook to an insert in a typed dataset


I need to trap an insert on an MS access table that uses a generated
typed table and row setup. I have to trap the insert and then hook up
and get the autonumber value for the insert. I have googled this and
cannot find a typed solution to the problem. I either abandon type
safety or solve this problem.

I have to work around 'Refresh the data table' that is greyed out.

Ta
Ken
Aug 8 '08 #1
2 1874
On Fri, 08 Aug 2008 16:55:17 +1000, Ken Foskey wrote:
I need to trap an insert on an MS access table that uses a generated
typed table and row setup. I have to trap the insert and then hook up
and get the autonumber value for the insert. I have googled this and
cannot find a typed solution to the problem. I either abandon type
safety or solve this problem.

I have to work around 'Refresh the data table' that is greyed out.
MyDataset is from the xsd designed Dummy is your table name. You will
add the TableAdapter to your application from the toolbox. I cannot find
this easily documented anywhere.

I finally figured this out. In my initialise:

DummyTableAdapt er.Adapter.RowU pdated += InsertDummy;

Then created the event:

private void InsertDummy(obj ect sender,
System.Data.Ole Db.OleDbRowUpda tedEventArgs args)
{
if (args.Statement Type == StatementType.I nsert)
{
MyDataSet.Dummy Row ball = (MyDataSet.Dumm yRow)args.Row;

// Include a variable and a command to retrieve the
identity value from the Access database.
int newID = 0;
OleDbCommand idCMD = new OleDbCommand("S ELECT
@@IDENTITY", DummyAdapter.Co nnection);

// Retrieve the identity value and store it in the
CategoryID column.
newID = (int)idCMD.Exec uteScalar();
ball.ID = newID; // my autonumber primary key
}
}
Creative Commons.
Aug 11 '08 #2
On Mon, 11 Aug 2008 11:10:13 +1000, Ken Foskey wrote:
On Fri, 08 Aug 2008 16:55:17 +1000, Ken Foskey wrote:
>I need to trap an insert on an MS access table that uses a generated
typed table and row setup. I have to trap the insert and then hook up
and get the autonumber value for the insert. I have googled this and
cannot find a typed solution to the problem. I either abandon type
safety or solve this problem.

I have to work around 'Refresh the data table' that is greyed out.

MyDataset is from the xsd designed Dummy is your table name. You will
add the TableAdapter to your application from the toolbox. I cannot
find this easily documented anywhere.

I finally figured this out. In my initialise:

DummyTableAdapt er.Adapter.RowU pdated += InsertDummy;

Then created the event:

private void InsertDummy(obj ect sender,
System.Data.Ole Db.OleDbRowUpda tedEventArgs args)
{
if (args.Statement Type == StatementType.I nsert) {
MyDataSet.Dummy Row ball = (MyDataSet.Dumm yRow)args.Row;

// Include a variable and a command to retrieve the
identity value from the Access database.
int newID = 0;
OleDbCommand idCMD = new OleDbCommand("S ELECT
@@IDENTITY", DummyAdapter.Co nnection);

// Retrieve the identity value and store it in the
CategoryID column.
newID = (int)idCMD.Exec uteScalar();
ball.ID = newID; // my autonumber primary key
}
}
Creative Commons.


And I am still getting concurrency violation. How do I solve this
problem.
Aug 11 '08 #3

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

Similar topics

1
6090
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
4
2275
by: chambersdon | last post by:
I have an application that needs to insert nulls into the database and I don't seem to be able to do this. I am currently trying to do this with a Typed DataSet but I can't seem to Insert Nulls (or udpate columns with a null value). I have a column in a test table called 'anInteger'. The Typed DataSet for this element has minOccurs="0" and the type = xs:int. To set this field to null I call the SetanIntegerNull method of my typed...
3
2767
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong typed properties from my original dataset Anyone that can point me to an example of how to sort my dataset and maintain the use of my typed properties would be greatly appreciated Thank, Freeon
1
9363
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't know why I cannot perform this casting operation properly. First off, I've got my Typed DataSet named "AuthInfo" declared and I then created an instance of that class. What I'd like to do next is to perform querying through the method...
3
9842
by: Ian Semmel | last post by:
The generated INSERT statement in a typed dataset has an INSERT statement followed by a SELECT statement which gets (I think) the value of the autoincremented ID. Question. How do I get hold of this value ?
4
9924
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard... code gen, code gen, code gen. What's at the end looks slick, but then there's a ton of generated code that I'm going to have to maintain now. I.e. I like typing things myself (don't like wizards) so I can know exactly what I've done.
2
5452
by: Simon | last post by:
Hi All, I'm hoping someone could advise me on how to make the following two operations atomic. I have a Places table and a PlaceBoundaryPoints table. When I create a "Place" I need to add a Place row and a number of PlaceBoundaryPoints (e.g. a place is made up of several boundary points, which are stored in a seperate table)
4
3114
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their comparisions) cleared? Thanks, Rachana
1
3618
by: creamy | last post by:
Hi Guys, There is the access DB, and the SQL server. I'm building an application that can insert a new person, and details, into a DB. (simple stuff?!) i'm however using a typed dataset created in visual studio to an OleDb datasource. i then use the insert function to try to insert into the DB. the problem is it keeps raising errors depending on the DB chosen (access or SQL) . if i create the dataset with access, it inserts only to...
0
9710
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
10593
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
6858
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
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
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.