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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Replication (2012)
 multiple insert listbox(all items),dropdownlist
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 05/05/2013 :  05:15:13  Show Profile  Reply with Quote
Is it possible to insert multiple records using listbox(all items),dropdownlist(selected value).

I have a table enrolnment that will be storing student history for any given academic year. The fields are; Studentid,academicyear,grade. studentid is bound to listbox, the other fields are bound to dropdownlist. the table is already prepopulated with prior years data.

Since the table will be keeping history hence there is no need for primary key.
for example the table has the following data;
studentid academicyear grade
1 2012 3
2 2012 3
3 2012 3
4 2012 3
5 2012 3
in a new academic year new records should be inserted like
studentid academicyear grade
1 2013 4
2 2013 4
3 2013 4
4 2013 4
5 2013 4
is this possible at a click of a button given all items in list box(studentid) and selected academicyear from dropdownlist.


James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 05/05/2013 :  21:12:14  Show Profile  Reply with Quote
Since the table will be keeping history hence there is no need for primary key.
Except in very rare cases, it is always better to have a primary key. If there are no single candidate keys, you could use a composite key or surrogate key.

That aside, to answer your question about sending multiple rows to the database - yes it can be done. What you would need to do is to extract the data that contains the selected items, pack it up and send it to the server, write code on the server to process that data.

There are multiple ways to do it. One would be to create a table-valued parameter and send that to the server - see here:

Other ways would be to construct an XML fragement and send that to the server, or send comma-separated values etc.
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000