Last post Oct 18, 2007 07:52 AM by naveen_arian
Jun 06, 2007 03:41 PM|Amanat|LINK
Can anyone help me in following:
i have a listbox and want that the data in the listbox to be added to database and display it in the form after i hit save button.
i m using asp 1.1, sql server 2000 and vb.net 2003
Web Application Projects
visual studio .net 2003
Jun 07, 2007 10:59 AM|Amanat|LINK
I am simplifying my Problem:
I have two listboxes, first listbox is populating the data from the database and then with the help of move button ,i am moving the selscted items from listbox 1 to listbox2 but, when i tried to save the data in listbox2 , i dont see those items getting
added to the database and on the UI.
Please Help...it's really urgent
Thanks in advance
Jun 08, 2007 05:03 AM|Benson Yu - MSFT|LINK
Please double check your code. Do you have the correct code to save the data from ListBox2 to the database? Maybe there occurs error when store data to database.
For the items in ListBox2 disappear after postback issue. Please check the EnableViewState property of ListBox2 is set to true or not.
This issue relate to your code and table in database. We have difficulty to fix it directly. However, we can give you our suggestions. Please check your code again. In addition, please debug the project step by step and see which step fails. Another important
point, please monitor the “T-SQL insert command” and confirm it is correct.
Jun 08, 2007 10:07 AM|Amanat|LINK
Thanks a lot for your help and kindness for helping others,i am really having a lot of problem, pls help me..as i earlier said, i have two listbixes-ldis1 and ldis2 --i am populating ldis1 with data from database and moving selected items from ldis1 to
ldis2 ---everything is working fine till here--but when i click on the save button --to add the items of ldis2 to database---nothing happens-also i get no error---also i am doing this with hepl of stored procedure--sp_insertsessdisc.also i m passing two arguments
to the stored procedure, sessid and discid...i dont know where to declare them..for sessid --i have property wriiten -so itz not giving error--but for discid --it gives error...
i m giving below code for your consideration:
conn.ConnectionString = ConfigurationSettings.AppSettings("ConnStr")
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_InsertSessDisc"
cmd.Parameters("@SessID").Value = SessID
cmd.Parameters("@DiscID").Value = Discid---giving error(not declared)
cmd.Connection = conn
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
pls help me..
Thanks, any help is appreciated..
Jun 11, 2007 03:22 AM|Benson Yu - MSFT|LINK
The code you posted seems well except the values of SessID and Discid, there isn’t any code of assigning values to these two variables in the "ButtonSave_Click" method. As the error point to Discid, please make sure Discid has been initialized and assigned
By the way, please use ExecuteNonQuery method instead of ExecuteReader method for insert operation. Then you can know if the row has been inserted by the return value.
Jun 13, 2007 03:44 PM|Amanat|LINK
I have finally resolved the problem, which was silly of me that i was coding on different button than actually on save.click button..and figured it out and it worked like magic.so otherwise everything was fine with the code above with little modification.
Oct 18, 2007 07:52 AM|naveen_arian|LINK
how r u
bro am facing the same problem as u were in saving listbox data to database.