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.
Author |
Topic |
jiyan
Starting Member
1 Post |
Posted - 2013-05-05 : 05:15:13
|
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 grade1 2012 32 2012 33 2012 34 2012 35 2012 3in a new academic year new records should be inserted likestudentid academicyear grade1 2013 42 2013 43 2013 44 2013 45 2013 4is this possible at a click of a button given all items in list box(studentid) and selected academicyear from dropdownlist.Thanks |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-05-05 : 21:12:14
|
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: http://msdn.microsoft.com/en-us/library/bb675163.aspxOther ways would be to construct an XML fragement and send that to the server, or send comma-separated values etc. |
|
|
|
|
|