textID.Text=Session["ID"].ToString();
textName.Text=Session["Name"].ToString();
if(Session["admin"].ToString()==""&&Session["lingdao"].ToString()==""&&Session["chengyuan"].ToString()=="")
{
Response.Redirect("login.aspx");
}
else
{
}
textID.Text=Session["ID"].ToString();
textName.Text=Session["Name"].ToString();
string sql="select JiHuaMuBiao from jihuamubiao where ID='"+Session["ID"].ToString()+"'";
SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connection"]);
SqlCommand comm=new SqlCommand(sql,conn);
try
{
conn.Open();
SqlDataReader reader=comm.ExecuteReader();
if(reader.Read())
textContent.Text=reader.GetValue(1).ToString();
}
catch(Exception ee)
{
Response.Write("<script languge=javascript> alert('"+ee.Message+"');</script>;");
}
finally
{
conn.Close();
}为什么在我的textContent上面不能显示数据库里面相应列的值呢?我调试的时候都没有到reader.read那句话,是不是我的sql语句错误了
textName.Text=Session["Name"].ToString();
if(Session["admin"].ToString()==""&&Session["lingdao"].ToString()==""&&Session["chengyuan"].ToString()=="")
{
Response.Redirect("login.aspx");
}
else
{
}
textID.Text=Session["ID"].ToString();
textName.Text=Session["Name"].ToString();
string sql="select JiHuaMuBiao from jihuamubiao where ID='"+Session["ID"].ToString()+"'";
SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connection"]);
SqlCommand comm=new SqlCommand(sql,conn);
try
{
conn.Open();
SqlDataReader reader=comm.ExecuteReader();
if(reader.Read())
textContent.Text=reader.GetValue(1).ToString();
}
catch(Exception ee)
{
Response.Write("<script languge=javascript> alert('"+ee.Message+"');</script>;");
}
finally
{
conn.Close();
}为什么在我的textContent上面不能显示数据库里面相应列的值呢?我调试的时候都没有到reader.read那句话,是不是我的sql语句错误了
textContent.Text=reader.GetValue(1).ToString();
==》textContent.Text=reader.GetValue(0).ToString();
还有,如是SQL语句错误,自己可以到SQL查询分析器上面执行一下,看看有没有错或有没有记录?
在这里我还想请教一个问题,就是在datagrid里面的一列模板里我放进了一个超链接,请问怎么实现点击一行里面的超链接就在另外一个页面显示对应行的数据呢?主要的问题是怎么实现点击当前行啊?不知道在哪里写代码