关于数据容错的问题,请帮帮忙:) DBNull和没有找到数据是两回事,你这么做不科学。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to: cnuninet(玉树临风胜潘安)还请提示 如果用 datareader, if (!da.Read()){ Response.Write("No Data Found");}如果用 dataset,if (ds.Tables["table1"].Rows.Count == 0){ Response.Write("No Data Found");} DataSet ds1;cn=new OleDbConnection(strConnecting);cn.Open();string strsqlsel2="select cpmc from cplrb where cpph='"+this.TxtPH.Text+"'";OleDbDataAdapter sda1=new OleDbDataAdapter(strsqlsel2,cn);ds1=new DataSet();sda1.Fill(ds1);OleDbCommand myCommand1 = new OleDbCommand(strsqlsel2,cn);if (ds1.Tables["cplrb"].Rows.Count==0){this.RegisterClientScriptBlock("ph","<script>alert('无法找到数据,请重新输入产品批号!')</script>");return;}else {TxtPM.Text=myCommand1.ExecuteScalar().ToString();}cn.Close();错在何处? try{ //do something}catch{ //show message} try{ //do something}catch{ //show message}请务必这样做,不然的话会出错 数据库 取数据从第四条数据才是取。sql 怎么写呢 关于id的问题 割腕含泪跪地拜求复制删除整个文件夹的方法~ 求DataGrid自定义分页的实现方法? 按钮委托事件无援无故自动丢失....郁闷啊! 我想从数据库中读一条string数据放到string变量中 Visual Studio 2008发现疑问求解 GridView绑定List<t>的问题,高手帮忙看一下啊 a.aspx.cs与a.aspx, ( HELP!HELP!) 天冷啊,散分热乎热乎! 我的这段代码错那了,我都调试两天了! 我是新手,请大家帮忙呀!!!!!!!!!!!!
还请提示
{
Response.Write("No Data Found");
}如果用 dataset,if (ds.Tables["table1"].Rows.Count == 0)
{
Response.Write("No Data Found");
}
cn=new OleDbConnection(strConnecting);
cn.Open();
string strsqlsel2="select cpmc from cplrb where cpph='"+this.TxtPH.Text+"'";
OleDbDataAdapter sda1=new OleDbDataAdapter(strsqlsel2,cn);
ds1=new DataSet();
sda1.Fill(ds1);
OleDbCommand myCommand1 = new OleDbCommand(strsqlsel2,cn);
if (ds1.Tables["cplrb"].Rows.Count==0)
{
this.RegisterClientScriptBlock("ph","<script>alert('无法找到数据,请重新输入产品批号!')</script>");
return;
}
else
{
TxtPM.Text=myCommand1.ExecuteScalar().ToString();
}
cn.Close();
错在何处?
{
//do something
}
catch
{
//show message
}
{
//do something
}
catch
{
//show message
}
请务必这样做,不然的话会出错