6
Reply

DataAdapter and DataRow

aravindakumar

aravindakumar

Nov 6 2003 9:05 AM
2.1k
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!

Answers (6)
Next Recommended Forum