Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Insertion of multiple records with 1 statement

Author  Topic 

Abid

110 Posts

Posted - 2013-03-07 : 08:28:38
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-07 : 09:52:26
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

110 Posts

Posted - 2013-03-07 : 22:56:34
@ 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

52326 Posts

Posted - 2013-03-08 : 00:13:40
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

110 Posts

Posted - 2013-03-08 : 01:10:27
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

52326 Posts

Posted - 2013-03-08 : 01:13:16
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

110 Posts

Posted - 2013-03-18 : 11:46:28
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

52326 Posts

Posted - 2013-03-18 : 12:53:41
you're welcome

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

Go to Top of Page

Abid

110 Posts

Posted - 2013-03-19 : 08:47:22
Thank you very much visakh16.
Go to Top of Page
   

- Advertisement -