DataAdapter and DataRow
I have this problem and I dont know the reason.
I need to fetch some information from database and display the corresponding "string" on the dropdownbox which was already populated from Database(say Language field).This is the code:
public void fillKnow()
{
DataSet ds_k=new DataSet();
SqlCommand cm=new SqlCommand("select * from knowledge where address=@add",con);
cm.Parameters.Add("@add",SqlDbType.Int);
cm.Parameters["@add"].Value=(int)Session["user_id"];
SqlDataAdapter dr=new SqlDataAdapter(cm);
SqlCommandBuilder sbul=new SqlCommandBuilder(dr);
dr.Fill(ds_k);
dt=ds_k.Tables[0];
if(dt.Rows.Count != 0)
{
drow=dt.Rows[0];
foreach(ListItem item in mother_tongue.Items)
if(item.Value==drow["mothertongue"].ToString())
item.Selected=true;
else
item.Selected=false;
}
}
"mothertongue" is a field in the table "knowledge"
and mother_tongue is the dropdownbox.
== sign in the if statement under foreach loop doesnt seem to "work".Is it a problem of casting?or anythingelse
vielen dank!
aravindakumarPosted Nov 7, 2003, 3:02 AM
david 0Posted Nov 6, 2003, 10:33 PM
aravindakumarPosted Nov 6, 2003, 6:52 PM
mikerPosted Nov 6, 2003, 1:45 PM
aravindakumarPosted Nov 6, 2003, 10:19 AM
mikerPosted Nov 6, 2003, 9:51 AM