Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2006, 03:13 AM
Registered User
 
Join Date: Oct 2005
Location: chandigarh, UT, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert rows in database in a bulk from grid

Hello all
         Could u tell me how to add rows in a database in bulk from a grid.Say i have added 10 rows to datagrid . Now with a single click i want to add these rows to database.

harry
  #2 (permalink)  
Old February 22nd, 2006, 03:19 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Have an Update/Insert button. In the click event, loop through the datagrid items. Pull each value you need and construct an Insert statement. Then execute the sql statement for each pass of the loop.

Are you using 2.0 or 1.1? The gridview can be made updatable. You can use SqlDataSource.Update()


Jim
  #3 (permalink)  
Old February 25th, 2006, 06:26 AM
Registered User
 
Join Date: Oct 2005
Location: chandigarh, UT, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi jim
        i am using 2.0.
Thanks

harry
  #4 (permalink)  
Old February 25th, 2006, 06:18 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

By using the SqlDataSource.Update() method, It will Update and/or Insert rows as needed. It looks a a row status to know if it is an Update, Insert or Delete.

Jim

  #5 (permalink)  
Old March 6th, 2006, 08:56 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

HI Jim

Sorry Harry, just jumping on the back of this one!

How do you make the whole of a gridview in an editable status?

Ta

Rit
  #6 (permalink)  
Old March 6th, 2006, 09:05 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Hi Jim

Sorry another question on this subject.. Probably a simple yes/no..

If I was to make the whole gridview updatable and use the SqlDataSource.Update() method do I still need to loop through each row of the gridview or is this already taken care or?

Many thanks

Rit
  #7 (permalink)  
Old March 6th, 2006, 11:46 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I know there are ways to make the whole grid editable. In that case, you would need to loop through the rows to Update and insert. Otherwise it is taken care of you by the sqldatasource.Update method.

 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bulk Insert TSQL in DTS – Rows Affected Count sjm SQL Server DTS 2 May 30th, 2008 11:40 AM
Bulk Insert snufse SQL Server 2000 9 December 17th, 2007 07:53 AM
bulk insert hymavathy_kr VB Databases Basics 1 May 17th, 2007 07:47 AM
INSERT Multiple rows to database at one time melkin Classic ASP Databases 19 April 11th, 2007 08:22 AM
INSERT Multiple rows to database melkin Classic ASP Professional 3 April 10th, 2007 09:03 AM



All times are GMT -4. The time now is 09:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.