Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2007, 06:11 AM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default help needed

hello friendz ..

 i m a newbie in the .net world. & having a problem in inserting the data in database.

 i want to insert the same data into the 2 different tables in the database at the same time.

 can u plzz suggest me the solution or give me the code of that in c# language.

 thanx.

Smmie
 
Old August 19th, 2007, 09:50 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you tried using a stored procedure, this seems like the most straightforward way to do something like this?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
 
Old August 20th, 2007, 08:59 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This requires two separate insert queries. This can be done with two queries strung and executed together (separated by a ";") like this:

INSERT INTO MyTable1(...) VALUES(...); INSERT INTO MyTable2(...) VALUES(...)

Or, as Doug suggests, put them together in a stored procedure. This also allows you to make the insert transactional.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed ramabharti Javascript How-To 1 December 7th, 2006 06:42 AM
Help needed rrvinod ADO.NET 0 October 5th, 2006 09:44 AM
help needed! paquito Beginning PHP 2 November 16th, 2005 11:51 AM
A Little help needed matthew01 ASP.NET 1.0 and 1.1 Basics 3 November 9th, 2005 11:29 AM
help needed kfarooq Java Databases 1 June 27th, 2003 05:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.