المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : retrieving values from datareader



C# Programming
08-24-2009, 09:51 AM
I am selecting a value,group_id,from the database table-group,using a datareader.Then i am assigning the result to the variable str_group.


But why is it giving the message'use of unassigned variable str_group???????My code is like this

string str_group;
OleDbCommand cmd1 = new OleDbCommand("select Group_id from Group_details where group='" + descriptiondpdwnlist.SelectedItem + "'",con1);
dr = cmd1.ExecuteReader();
while (dr.Read ())
{
str_group = (string)dr[0];
}

string cmd2 = "select description from description_details where group_id='"+str_group +"'";