Click here to Skip to main content
15,668,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am working on windows application, in which I am saving combo box selected value to database. I wrote the code as follows:-
slc.Parameters["@Cust_Name"].Value = cmbCust_Name.SelectedValue.ToString();

cmbCust_Name is the name of combo box. when I am saving the data to the database, System.Data.DataRowView is saved instead of actual data.

Any Help ??

Thanks In Advance !!!

don't have idea about windows but in web
we do like(Query-insert into emp(state) values(@a))
Share this answer
Ank_ush 5-Dec-12 14:12pm    
you are right, I tried to use cmbCust_Name.SelectedItem.toString() and even cmbCust_Name.SelectedText, but still it is saving System.Data.DataRowView
Surendra0x2 5-Dec-12 14:20pm    
refer this Link
may be this can sortout ur problem
Surendra0x2 5-Dec-12 14:23pm    
slc.Parameters["@Cust_Name"].Value = cmbCust_Name.SelectedValue.Text;

try this
Ank_ush 5-Dec-12 14:32pm    
Not working. I tried this slc.Parameters["@Cust_Name"].Value = cmbCust_Name.Text;
value was properly saved. if you use cmbCust_Name.SelectedValue, then the code should be cmbCust_Name.SelectedValue.TOStrting();
Surendra0x2 5-Dec-12 14:39pm    
yes because value is integer so we need typecasting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900