文本框T1中取到了上一个页面传过来的值,想利用该值条件查询后数据绑定到各文本框中,可怎么都显示不出数据来.代码如下:private void Page_Load(object sender, System.EventArgs e)
{
T1.Text=Request.QueryString["id"];
if(!IsPostBack)
{
SetBind();
}
}private void SetBind()
{
OracleConnection oCon = oBase.oConnect();
string sSql = "select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id="+T1.Text.ToString().Trim()+"";
OracleDataReader reader = oBase.ExecuteSqlRow(sSql,oCon);
if(reader.Read())
{
TextBox1.Text=reader["hb_no"].ToString().Trim();
TextBox2.Text=reader["godate"].ToString().Trim();
TextBox3.Text=reader["amound"].ToString().Trim();
TextBox4.Text=reader["jcamound"].ToString().Trim();
TextBox5.Text=reader["ryamound"].ToString().Trim();
TextBox6.Text=reader["bxamound"].ToString().Trim();
}
reader.Dispose();
oCon.Close();
}
{
T1.Text=Request.QueryString["id"];
if(!IsPostBack)
{
SetBind();
}
}private void SetBind()
{
OracleConnection oCon = oBase.oConnect();
string sSql = "select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id="+T1.Text.ToString().Trim()+"";
OracleDataReader reader = oBase.ExecuteSqlRow(sSql,oCon);
if(reader.Read())
{
TextBox1.Text=reader["hb_no"].ToString().Trim();
TextBox2.Text=reader["godate"].ToString().Trim();
TextBox3.Text=reader["amound"].ToString().Trim();
TextBox4.Text=reader["jcamound"].ToString().Trim();
TextBox5.Text=reader["ryamound"].ToString().Trim();
TextBox6.Text=reader["bxamound"].ToString().Trim();
}
reader.Dispose();
oCon.Close();
}
T1里的值正确吗?
2. select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id="+T1.Text.ToString().Trim() 该语句你确定没错吗?(“id”的这个取值是不是在数据库的表里面?)
string sSql = "select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id="+T1.Text.ToString().Trim()+"";
oCon.Open();//---------------------------
OracleDataReader reader = oBase.ExecuteSqlRow(sSql,oCon);
while(reader.Read())// --------------------
{
TextBox1.Text=reader["hb_no"].ToString().Trim();
TextBox2.Text=reader["godate"].ToString().Trim();
TextBox3.Text=reader["amound"].ToString().Trim();
TextBox4.Text=reader["jcamound"].ToString().Trim();
TextBox5.Text=reader["ryamound"].ToString().Trim();
TextBox6.Text=reader["bxamound"].ToString().Trim();
}
{
T1.Text=Request.QueryString["id"];
}
Request.QueryString["id"]值为15,不为空
sSql语句结果为空
id是number类型,用序列方式生成,数据库中已有多条数据,其中一条为:id hb_no godate amound jcamound ryamound bxamound15 B7908 20070602 2300 120 50 20
select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id=15
select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id=15但文本框中却不显示结果,晕啊,请高手们帮忙看看,是哪出了问题,多谢!