multiple rows of a single table
Posted
by
Amanjot Singh
on Stack Overflow
See other posts from Stack Overflow
or by Amanjot Singh
Published on 2011-01-09T09:51:08Z
Indexed on
2011/01/09
9:53 UTC
Read the original article
Hit count: 222
multiple-tables
i am having a table with 3 col. viz id,profile_id,plugin_id.there can be more than 1 plugins associated with a single profile now how can i fetch from the database all the plugins associated with a profile_id which comes from the session variable defined in the login page when I try to apply the query for the same it returns the data with the plugin_id of the last record the query is as follows
SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]), con);
SqlDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
while (dr1.Read())
{
Session["edp1"] = Convert.ToInt32(dr1[0]);
}
}
dr1.Close();
cmd1.Dispose();
© Stack Overflow or respective owner