p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Database > SQL Language
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2009, 03:55 AM
Friend of Wrox
Points: 577, Level: 8
Points: 577, Level: 8 Points: 577, Level: 8 Points: 577, Level: 8
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using store Procedure to insert in 2 tables

Hi,

I need a store procedure that will take 2 parameters Name & age. It will be entered in 2 tables namely employee - will contain Name & employee_details - will contain age. employee is the main table which has a identity column empID as Primary key & employee_detail table is the detail table with empID as Foreign Key.

Now what would be the code for my store procedure if I have to insert 2 values - Name & Age for employees from a Asp.Net page using this store procedure.


Urgent Pls help !!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old September 28th, 2009, 08:17 AM
Friend of Wrox
Points: 1,882, Level: 17
Points: 1,882, Level: 17 Points: 1,882, Level: 17 Points: 1,882, Level: 17
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: May 2004
Location: India
Posts: 563
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Please check the following link for examples:
http://www.csharpfriends.com/Article...x?articleID=78
http://www.dotnetspider.com/forum/39...rocedures.aspx

Example:
Code:
string username = ... // get username from user
string password = ... // get password from user
SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=MyDB;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("InsertUser", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;
command.Parameters.Add("@Password", SqlDbType.VarChar).Value = password;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();
You can write SP which will accept the required parameters and insert data in one or more tables.
__________________
Om Prakash Pant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Store procedure help... RinoDM SQL Server 2000 7 August 11th, 2008 08:09 PM
Store procedure help ??? RinoDM SQL Server 2000 8 May 1st, 2008 04:03 PM
store procedure if else problem krshekhar SQL Language 0 February 20th, 2008 05:31 AM
Store Procedure For Attendance prasanta2expert SQL Server 2000 2 January 8th, 2008 03:37 AM
Store Procedure sureshyuga SQL Server 2000 0 May 18th, 2007 02:49 AM



All times are GMT -4. The time now is 05:14 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc