| | |
WizardSteps-> SQL Insert -> Grab ID field
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
Hi all...
I have an issue that I've been puzzling over here and there for about a week. I should say that I'm new to ASP.NET and new to this forum. I Had some experience with VB6 some years back then my career took a left turn. Now I'm back, teaching myself ASP.NET/VB.NET with Visual Studio 2005. (Also learning classic ASP... don't ask). So it's likely that the problem is simply my approach and inexperience. With that said and an apology for a long post :
I created a web app that is primarily a multi-step wizard control which gathers input, takes the user down several possible paths, offers choices, and calculates some variables based on those choices. So far so good.
Now I have lots of validated data and I'm ready to add a record to my SQL 2000 table. So in my aspx.vb file I capture the click event of the wizard's FINISH button. I create a SQLDataSource object from a connectionstring I already have in my web.config file. I use a well thought out and thoroughly tested text command as the data source... (I know I should use a stored procedure to avoid injection attacks but I would prefer to just get this working and deal with that in ver.2. This is an internal app for a very small group).
Anyway, I setup all of the necessary InsertParameters etc and inside of a try/catch I perform the insert command and grab the number of rows affected with :
And my record inserts into my table beautifully.
Here's the problem...
I need to grab the Identity field of the record I just added. I've done a lot of research and as a result I've added
to my query string. I just can't figure out how to get that ID's data back. I need to use it to change a text property of a label in the next Wizardstep. I also had errors telling me that "MY_ID" wasn't declared so I tried adding it to the InsertParameters list. Kinda clunky and it only stopped the error message... it didn't give me any value back.
I tried :
Knowing that wouldn't work but I just can't seem to find a working example or figure it out. Which now leaves me thinking that my approach is just wrong.
Any suggestions ?
Thanks in advance and also once again... my apologies for giving more info than you probably needed.
I have an issue that I've been puzzling over here and there for about a week. I should say that I'm new to ASP.NET and new to this forum. I Had some experience with VB6 some years back then my career took a left turn. Now I'm back, teaching myself ASP.NET/VB.NET with Visual Studio 2005. (Also learning classic ASP... don't ask). So it's likely that the problem is simply my approach and inexperience. With that said and an apology for a long post :
I created a web app that is primarily a multi-step wizard control which gathers input, takes the user down several possible paths, offers choices, and calculates some variables based on those choices. So far so good.
Now I have lots of validated data and I'm ready to add a record to my SQL 2000 table. So in my aspx.vb file I capture the click event of the wizard's FINISH button. I create a SQLDataSource object from a connectionstring I already have in my web.config file. I use a well thought out and thoroughly tested text command as the data source... (I know I should use a stored procedure to avoid injection attacks but I would prefer to just get this working and deal with that in ver.2. This is an internal app for a very small group).
Anyway, I setup all of the necessary InsertParameters etc and inside of a try/catch I perform the insert command and grab the number of rows affected with :
ASP.NET Syntax (Toggle Plain Text)
RowsAffected = SqlDataSource1.Insert()
Here's the problem...
I need to grab the Identity field of the record I just added. I've done a lot of research and as a result I've added
ASP.NET Syntax (Toggle Plain Text)
...SELECT @MY_ID = SCOPE_IDENTITY();
I tried :
ASP.NET Syntax (Toggle Plain Text)
VNewID = SqlDataSource1.InsertParameters.Item("My_ID")
Any suggestions ?
Thanks in advance and also once again... my apologies for giving more info than you probably needed.
![]() |
Similar Threads
- SQL insert help!! (VB.NET)
- insert csv file into mysql through php (PHP)
- Access INSERT problem (MS Access and FileMaker Pro)
- Database not being populated.... (Java)
- parsing csv file (PHP)
- Rows not added correctly when using 'INSERT' (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Messagebox
- Next Thread: login forms with asp.net
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# cac checkbox class commonfunctions compatible content contenttype countryselector courier dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal formview gridview gudi iframe iis javascript listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers






. You have some values your want submit to a DB. Once you submit the data into a new row you want to retreive the Row GUID you just inserted?