954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sessions and Relational Databases in ASP.Net

Hello,

I am just starting out with ASP.Net using VB.Net.

I am trying to build a football website for my football club that has a backend CMS system. I have the database designed with primary and foerign keys in SQL Server 2005.

I would like some help to:
1) Insert information into a table containing a primary key ?
2) Get that primary key back and then either insert into a new table with new data or to store the ID in a session ?

any help would be much appreciated

Thanks

SunnySideUp
Light Poster
30 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

You can retrieve your primary key anytime when you want to use it as foreign key to another table, meaning you must have sub query on your stored procedures.
This might be helpfull, you can learn a lot about this
http://www.1keydata.com

Mongz
Light Poster
42 posts since Apr 2009
Reputation Points: 7
Solved Threads: 1
 

You can insert values directly in to a PK column depending on how you have the column configured but it sounds like you're referring to an autoincrementing PK value? If so you can Select SCOPE_IDENTITY() after your insert runs to return the PK's value.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

You can use the scope_identity to get the latest identity inserted.

questpond
Newbie Poster
19 posts since Feb 2011
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: