Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 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 May 18th, 2008, 02:19 AM
svk svk is offline
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple records in database

i have multiselect listbox in which any no of values can be slected
i want to insert this multiple values in sql table
how do i use the insert statement
will the records be added in different rows or will it be added in same row like 1,3,4,5
how do i do it


 
Old May 18th, 2008, 03:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It depends on what you need to accomplish.

Typically you have a table where you store a record for each item that is selected in the listbox. In the long run, this makes it easier to maintain and query your data. Storing it as single value makes it really difficult to query that data and treat it as relational.

If you also need to be able to edit the list again, you can take two approaches:

1. First, delete all items from the table. Then loop through the listbox and insert only the selected items.

2. Loop through the listbox and delete the items that are not selected from the database table and insert the items that are selected.

The second case is useful if you need to store more data about the item than its value alone (for example, the date/time it was inserted).

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate multiple records into one Raman Pahwa SQL Server ASP 1 August 19th, 2008 02:57 PM
adding multiple records Vince_421 VB Databases Basics 4 February 28th, 2007 07:22 AM
Update Multiple Records cancer10 Classic ASP Databases 0 October 25th, 2006 01:01 AM
Multiple records!!!! vmclear04 Classic ASP Databases 1 August 24th, 2004 04:53 AM
How Can I Update Multiple Records Lucy SQL Server ASP 3 March 18th, 2004 03:19 PM





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