Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Please Explain | Verify | Confirm....

Posted on 2004-09-29
9
Medium Priority
?
223 Views
Last Modified: 2010-04-15
I really need help.  

I have to build a web application in c# where there are several controls (such as listbox controls) that will post multiple selections to a database.  My frustration is in the fact that I cannot find any documentation that demonstrates how to accomplish this.  All the documentation I have located shows you how to build a manual array list to populate the control and then after clicking a button, display those items selected in a label control.  WOW!!!!!

My question is, what do you do (or use) when you want to trap multiple selections from a control (like the listbox) and post them to a database?

Here is an example of an webform that encompasses my scenario:
Webform:
Name of Car:[textbox]
Users of Car:[listbox or family members]

I need to be able to store the values of the listbox selected so that I can at any point run a query against this column to find out which car or what cars family member 3 drives.

I figure there are many e-com sites out there that emplore this functionality, I just can't find an example of the code.

Thank you for your patience in reading this.

Sincerely,
Tim
0
Comment
Question by:TMF123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 15

Accepted Solution

by:
praneetha earned 1000 total points
ID: 12183676
after they select the family memebers from a list and click submit button

at the button click you can write a sql statement to store it in database / use a stored procedure...

http://www.c-sharpcorner.com/Database.asp

good luck
0
 

Expert Comment

by:yanzickp
ID: 12186881
I haven't tried it, but you should be able to utilize a data set and update the data set programatically based on what items in the list are selected.

One way that I did something similar was using a data grid with a select/remove button...  
0
 
LVL 10

Assisted Solution

by:123654789987
123654789987 earned 1000 total points
ID: 12188429
Maintain a datatable.

DataTable dtCar = new DataTable();
dtCar.Columns.Add("CarName");
dtCar.Columns.Add("CarUser");

Store the information u have in this format in the

DataRow dr = dtCar.NewRow();
dr[0] = "Car1";
dr[1] = "Uses1";
dtCar.Rows.Add(dr);

U can use this database to same the information about a car and its users. when u have to update the user u can get the inforamtion from this datatable and insert the record in the database.

OracleConnection myConnection = new OracleConnection(myConnectionString);
OracleCommand myCommand = new OracleCommand(myExecuteQuery, myConnection);
myCommand.Connection.Open();

for(int i = 0 ; i < = dtCar.Rows.Count -1 ; dtCar++)
{
  myExecuteQuery= "Insert into Car(Carname, CarUser) values ('" + dtCar.Rows[i][0] + "', '" + dtCar.Rows[i][1] + "') "

     myCommand.ExecuteNonQuery();
 }

myConnection.Close();


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TMF123
ID: 12190017
Ok, sounds feasible.  However, what if the complexity of the scenario increases such as this:

What if 3/4 of the data from the web form is going to be submitted to one table and all of the listbox controls values submited to other tables.  All at the same time when the user hits submit.

Questions:
How are you able to get the ID value from the main table to submit into the other tables used for the listbox control values?  Do you need to script the SQL in such as a way that the data is submitted into the main table first then the others?

I assume you would need to produce a datatable for each listbox control you have in your webform that has the proprerty set for multiple select?

Thank you for your help.

Regards,

Tim
0
 

Author Comment

by:TMF123
ID: 12192584
One of the things I don't understand is how does the datatable know where to get the data from? Where do you plug-in the control for the listbox?
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12192928
you just have to do it some button click or something
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question