473,378 Members | 1,372 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,378 software developers and data experts.

Please Help: How to get auto-generated code to return new ID of inserted record?

I am using VS 2008 SP1, ASP.NET 3.5, VB.NET, MySQL (latest version).

I created a new dataset using VS. In the ds I have a users table. I let it
create the "Fill, GetData" functions in the usersTableAdapter.

When I call the INSERT command, how do I get it to return the ID (the PK) of
the newly created record?

I pulled up the properties of the TableAdapter, then went to the
InsertCommand/Parameters. I added a parameter (for the pk I want) and made
it have a "ReturnValue" Direction.

What am I missing?

In my code I did a "Goto Definition" of the Insert command I called. It
brought me to the VS "auto generated code". I noted that the auto-generated
code does an ExecuteNonQuery. I suspect this needs to change but I don't
know how to! I don't want to edit the code directly since it's
"auto-generated".

Please help!!!
Oct 5 '08 #1
2 2159
Maybe this can help

http://www.codeproject.com/KB/database/MySqlUtil.aspx

Or maybe do some googling on:
LAST_INSERT_ID
AUTO_INCREMENT

Plus the other keywords you list:

TableAdapter Insert MySql

"Bobby Edward" <bo***@nobody.comwrote in message
news:OQ****************@TK2MSFTNGP03.phx.gbl...
>I am using VS 2008 SP1, ASP.NET 3.5, VB.NET, MySQL (latest version).

I created a new dataset using VS. In the ds I have a users table. I let
it create the "Fill, GetData" functions in the usersTableAdapter.

When I call the INSERT command, how do I get it to return the ID (the PK)
of the newly created record?

I pulled up the properties of the TableAdapter, then went to the
InsertCommand/Parameters. I added a parameter (for the pk I want) and
made it have a "ReturnValue" Direction.

What am I missing?

In my code I did a "Goto Definition" of the Insert command I called. It
brought me to the VS "auto generated code". I noted that the
auto-generated code does an ExecuteNonQuery. I suspect this needs to
change but I don't know how to! I don't want to edit the code directly
since it's "auto-generated".

Please help!!!


Oct 5 '08 #2
"sloan" <sl***@ipass.netwrote in message
news:uD**************@TK2MSFTNGP04.phx.gbl...
Maybe this can help

http://www.codeproject.com/KB/database/MySqlUtil.aspx

Or maybe do some googling on:
LAST_INSERT_ID
AUTO_INCREMENT

Plus the other keywords you list:

TableAdapter Insert MySql
Thanks Sloan. I've been digging for 2 hours but haven't been able to find a
solution.

Some have suggested checking the "Refresh the data table" checkbox in the
Advanced Options of the Tabledapter Configuration Wizard, but for some
reason this doesn't modify anything as people have suggested. (It's
supposed to add a SELECT statement after the INSERT query. But it doesn't
for me.)

Any more suggestions would be appreciated...

I'm sure that there are alot of people using MySQL with the VS TableAdapter
dataset stuff.

Hopefully they'll come to my rescue!
Oct 5 '08 #3

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

Similar topics

2
by: James Hull | last post by:
Hi All: I am new in the Perl world. So far I have installed cygwin and Perl 5.8.0 along with Perl DBI and DBD::Oracle modules. NowI am trying to install Perl Tk on my PC (Windows 2K). I have...
21
by: Applebrownbetty | last post by:
Hi, I've run into a problem with IE 6 vs. Mozilla when displaying a completely CSS positioned page, and was wondering if any resident CSS guru might quickly be able to find the problem(s). Thank...
2
by: sorCrer | last post by:
Hi Guru's, Going crazy with this problem! I fill a dataset in asp.net with a 'FOR XML AUTO' query and Output it back to the browser. > DS.WriteXml(Response.OutputStream,...
4
by: Nip | last post by:
I am trying to make a database for my test participants. I have 10 participants and have a table with them called participants which includes an auto number ID and then the participant number and...
2
by: James Hancock | last post by:
In case any of you have been as frustrated with the Help implimentation in ..NET as me, here's a way around the stupidity of using the current window as the parent for the help window (yes, you...
5
by: Mr Brown | last post by:
Hi, I have a div <div class="lrgBG">, followed by a footer div <div class="lrgFooter">. I have an image and a table in the lrgBG div, image is floating left and the table is floating right. the...
19
by: yxq | last post by:
Hello, I want to get the string resource from DLL file, the code work well for Vista x86, but it will not work on Vista x64, why? can anyone help to view the code below? thank you very much. ...
0
by: [Cool staff!||Hi! I think this need for || Help me | last post by:
http://con-cern.org/files/2007/5/xenical-21024312.html cheap xenical http://con-cern.org/files/2007/5/auto-21024411.html auto loan refinance ...
61
by: warint | last post by:
My lecturer gave us an assignment. He has a very "mature" way of teaching in that he doesn't care whether people show up, whether they do the assignments, or whether they copy other people's work....
1
by: innivive | last post by:
I am having a problem with having margins display correctly in IE7, Firefox and Safari. I am not sure if it is the "double margin error" or something else. Any help would be appreciated. The file...
1
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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.