shahab
Junior Contributor
Hi there,
I have two tables.In the first one there are userAccounts and in the second one users urls.(Ms Sql server 2000)
Now I want to show both the Accounts Info and url for a user in a datagrid.(C# Please)
For one DataBinding I use this:
-----------------------------------------------------------
string selectCmd = "SELECT username,password,role,email,studentcode,SignDate FROM tblUserAccounts WHERE username=@Username";
SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, objConn);
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Username", SqlDbType.NVarChar, 50));
myCommand.SelectCommand.Parameters["@Username"].Value ="m1";
//Session["username"].ToString();
DataSet ds = new DataSet();
myCommand.Fill(ds, "tblUserAccounts");
MyDataGrid.DataSource= ds.Tables["tblUserAccounts"].DefaultView;
MyDataGrid.DataBind();
-------------------------------------------------------------------------
1-What should I do to show both of them?
2-Can i use join?How?
+" UNION SELECT * FROM tblUrl WHERE username=@Username";
3-So many thanks!:-\
I have two tables.In the first one there are userAccounts and in the second one users urls.(Ms Sql server 2000)
Now I want to show both the Accounts Info and url for a user in a datagrid.(C# Please)
For one DataBinding I use this:
-----------------------------------------------------------
string selectCmd = "SELECT username,password,role,email,studentcode,SignDate FROM tblUserAccounts WHERE username=@Username";
SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, objConn);
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Username", SqlDbType.NVarChar, 50));
myCommand.SelectCommand.Parameters["@Username"].Value ="m1";
//Session["username"].ToString();
DataSet ds = new DataSet();
myCommand.Fill(ds, "tblUserAccounts");
MyDataGrid.DataSource= ds.Tables["tblUserAccounts"].DefaultView;
MyDataGrid.DataBind();
-------------------------------------------------------------------------
1-What should I do to show both of them?
2-Can i use join?How?
+" UNION SELECT * FROM tblUrl WHERE username=@Username";
3-So many thanks!:-\