SQL 语句如下:
string line1SJFloat = "select Convert(varchar(50),Convert(decimal(8,2),Round(sum(passqty)*1.0/sum(qty)*100,2,0))) + '%' as Yield from ir where ir.line ='01' and ir.step=(select config.cdesc from config where config.code='01')";C#语句如下: myconn.Open();
SqlDataReader Line1SJRead = line1SJSelectFloat.ExecuteReader();
TextBox7.Text = Line1SJRead.GetString(0).ToString();
Line1SJRead.Read();
myconn.Close();现在的问题是,在SELECT的结果不为空时正常,但当SELECT结果为空时,提示说"在没有任何数据时进行无效的读取尝试".请问这个问题怎么解决,怎么可以将空值也显示出来,谢谢!
string line1SJFloat = "select Convert(varchar(50),Convert(decimal(8,2),Round(sum(passqty)*1.0/sum(qty)*100,2,0))) + '%' as Yield from ir where ir.line ='01' and ir.step=(select config.cdesc from config where config.code='01')";C#语句如下: myconn.Open();
SqlDataReader Line1SJRead = line1SJSelectFloat.ExecuteReader();
TextBox7.Text = Line1SJRead.GetString(0).ToString();
Line1SJRead.Read();
myconn.Close();现在的问题是,在SELECT的结果不为空时正常,但当SELECT结果为空时,提示说"在没有任何数据时进行无效的读取尝试".请问这个问题怎么解决,怎么可以将空值也显示出来,谢谢!
解决方案 »
- C#调用c++的dll 出现“尝试读取或写入受保护的内存 这通常指示其他内存已损坏”
- log explorer 4.2 问题
- mysql数据库连接莫名奇妙的关闭
- 郁闷死了,csdn就没搞手能解决图片连接问题了吗 100分 郁闷在线等
- 关于datagrid的在新的页面中编辑问题.
- 水晶报表for vs2013
- Serializa / Deserializa 菜问题
- 在c#中的数据类型转换的问题
- 用DataGrid中加入ComboBox,显示和修改数据库的小例子。。。。。
- 请问如何在DLL中使用一个变量,使其在主程式的运行期间一直生存?而且仅在DLL内部使用。
- SqlCommand的不同含意 初学者
- 求教图片上传功能
SqlDataReader Line1SJRead = line1SJSelectFloat.ExecuteReader();if(Line1SJRead.Read())
TextBox7.Text = Line1SJRead.GetString(0).ToString();Line1SJRead.Close();
myconn.Close();
或者try
{
}
catch(()
{}
SqlCommand cmd = new SqlCommand("line1SJFloat", myconn);
object obj = cmd.ExecuteScalar();
if (obj != null)
{
TextBox7.Text = obj.TOString();
}
myconn.Close();