传值,绑定到文本框问题.很简单的问题,在线等!
文本框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();
}
------解决方案--------------------reader里 没有取到值
看看sql语句 连接串都对否?
------解决方案--------------------Request.QueryString[ "id "];这个值是否为空调试一下就知道了
------解决方案--------------------1. T1.Text=Request.QueryString[ "id "];
T1里的值正确吗?
2. select hb_no,godate,amound,jcamound,ryamound,bxamound from chengke where id= "+T1.Text.ToString().Trim() 该语句你确定没错吗?(“id”的这个取值是不是在数据库的表里面?)
------解决方案--------------------OracleConnection oCon = oBase.oConnect();
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();
}
------解决方案--------------------if(!Request.QueryString[ "id "].Equals(string.Empty))
{
T1.Text=Request.QueryString[ "id "];
}
------解决方案--------------------直接输出 Response.write(sSql); 看下查询语句有什么问题
------解决方案--------------------OracleDataReader reader = oBase.ExecuteSqlRow(sSql,oCon);
===========================================================
你再看看oBase还有什么方法 你确定这个是你需要的么?