G
Guest
I am having problem accessing a datareader from the aspx page here is my code:
private void Page_Load(object sender, System.EventArgs e)
{
BindData();
}
public void BindData()
{
objConn.Open();
SqlCommand selectCmd = new SqlCommand("SELECT * FROM tblFault
WHERE ID=" + Request.QueryString["id"] ,objConn);
SqlDataReader dr = selectCmd.ExecuteReader();
dr.Read();
// dr.Close();
objConn.Close();
}
when i try to call the dr in the aspx page i get error message:
The name 'dr' does not exist in the class or namespace 'ASP.details_aspx' ..
but it does exist
Here is the code i am using to call the dr in the aspx page
(I am imprting system.data and system.data.sqlclient namespace aswell)
<td><%# dr["ID"]%></td>
any idea why i am getting this error message?
private void Page_Load(object sender, System.EventArgs e)
{
BindData();
}
public void BindData()
{
objConn.Open();
SqlCommand selectCmd = new SqlCommand("SELECT * FROM tblFault
WHERE ID=" + Request.QueryString["id"] ,objConn);
SqlDataReader dr = selectCmd.ExecuteReader();
dr.Read();
// dr.Close();
objConn.Close();
}
when i try to call the dr in the aspx page i get error message:
The name 'dr' does not exist in the class or namespace 'ASP.details_aspx' ..
but it does exist
Here is the code i am using to call the dr in the aspx page
(I am imprting system.data and system.data.sqlclient namespace aswell)
<td><%# dr["ID"]%></td>
any idea why i am getting this error message?