SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Insertion of multiple records with 1 statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Abid
Posting Yak Master

Pakistan
105 Posts

Posted - 03/07/2013 :  08:28:38  Show Profile  Reply with Quote
Can i insert multiple records in SQL Server 2005 with single insert statement, by using vb.net.

On my vb.net ProdInfo form i have 12 textbox in 3 rows, (4 txtbox in each row) 4x3, which will be filled by the user and press the Submit button and all the 4 records will be inserted into Database. Is it possible? Please guide me.

James K
Flowing Fount of Yak Knowledge

3633 Posts

Posted - 03/07/2013 :  09:52:26  Show Profile  Reply with Quote
Yes, you can insert all of those 12 in a single insert statement, assuming they are all going into a single table. What you will need to do is to send them to the server as parameters of a stored procedure and have the stored procedure insert the values into the table.

There are other variations of that as well, but doing it the way I described above is perhaps the simplest. Google for some sample code or tutorials - here is one, for example: http://msdn.microsoft.com/en-us/library/yy6y35y8(v=vs.71).aspx
Go to Top of Page

Abid
Posting Yak Master

Pakistan
105 Posts

Posted - 03/07/2013 :  22:56:34  Show Profile  Reply with Quote
@ James K
Thank you sir, but i've never used Stored Procedure in my programming. Please guide me further that how do i do it. my project is pending for this one thing only.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/08/2013 :  00:13:40  Show Profile  Reply with Quote
see

http://net-informations.com/vbprj/ado.net-dataproviders/stored-procedures.htm

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Abid
Posting Yak Master

Pakistan
105 Posts

Posted - 03/08/2013 :  01:10:27  Show Profile  Reply with Quote
very well visakh, i've now learned a bit that how to create store procedure. But now as my problem is concerned. I will declare variables in stored procedure, which will receive the values from vb.net, which i will send by textboxes or comboboxes etc. right? Am i right with this concept?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/08/2013 :  01:13:16  Show Profile  Reply with Quote
quote:
Originally posted by Abid

very well visakh, i've now learned a bit that how to create store procedure. But now as my problem is concerned. I will declare variables in stored procedure, which will receive the values from vb.net, which i will send by textboxes or comboboxes etc. right? Am i right with this concept?


Yep you're right

But they're called parameters and not variables. They can be used to return values to calling application (vb.net) as well.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Abid
Posting Yak Master

Pakistan
105 Posts

Posted - 03/18/2013 :  11:46:28  Show Profile  Reply with Quote
Hi Everyone. my problem is solved. Thank you very much to all of you, who participated me with this problem.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/18/2013 :  12:53:41  Show Profile  Reply with Quote
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Abid
Posting Yak Master

Pakistan
105 Posts

Posted - 03/19/2013 :  08:47:22  Show Profile  Reply with Quote
Thank you very much visakh16.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000