473,767 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 usersTableAdapt er.

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 "ReturnValu e" 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 2182
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.c omwrote in message
news:OQ******** ********@TK2MSF TNGP03.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 usersTableAdapt er.

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 "ReturnValu e" 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.ne twrote in message
news:uD******** ******@TK2MSFTN GP04.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
4820
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 tried both Tk804.025 and Tk804.025_beta2. However, both versions failed with following errors. It appeared that the command "perl Makefile.PL" ran successfully, but the "make" command failed. I also ran "perl -Mblib demos/widget". It was complaining...
21
2817
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 you. In IE, the page looks how I want it to look (picture below): www.sunbadgeco.com/sunmetal/ie.jpg In Mozilla Firefox, somehow it's not quite right (pic below): www.sunbadgeco.com/sunmetal/mozillafirefox.jpg
2
3733
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, XmlWriteMode.IgnoreSchema) No matter what I do I get the first nodes "<" encoded as "&lt;" This
4
1526
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 start date. Now I want to rank these participants. So I have created 3 more tables one is called rankdescription and includes 5 ranking descriptions which all 10 participants will have to rank. The 2nd table is rankdate and includes 8...
2
2988
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 can't go back and forth and look in the help file and then do what it says in the program! That would be to damn easy!). I found the best possible way to do all of this stuff. You could extend this to handle events etc. if you wished but this is...
5
4518
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 problem is, which you can see below is that in firefox the lrgBG div doesn't seem to be holding the IMG & Table, and not expanding to the height of them. this is what i need help with please. Looks correct in IE allthough CSS is wrong...
19
1916
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. ////////////////////////////////////////////////////////////////////////////////// Public Class GetResourceStringFromFile Private Declare Function LoadLibrary Lib "kernel32" Alias
0
1299
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 http://tag-dev.jot.com/WikiHome/pharmacy/xenical_html___117970823717048_96302128227356?jot.viewName=xenical.html&theme=none buy xenical http://tag-dev.jot.com/WikiHome/pharmacy/auto_html___117970831070975_10304845439619?jot.viewName=auto.html&theme=none auto loan refinance ,...
61
3564
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. Furthermore, he doesn't even mark the assignments, but rather gives tips and so forth when going over students' work. To test students' capabilities for the purpose of state exams and qualifications though, he actually sits down with us at a...
1
3114
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 tabs at the top content area should be flush left and the light blue frame should line up under the logo graphic. Looks great in Safari and Firefox but I can't get it to line up in IE7. http://www.thinairdigital.com/tdi Any help would be...
0
9404
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
10009
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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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
8835
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...
1
7381
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
5279
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
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
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.