SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
SqlDataReader sdr=cmd.ExecuteScalar();
this.title.Text=sdr["proName"].tostring; //title是一个label
sdr.Close();
con.Close();这段代码哪里错了?请帮帮我啊
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
SqlDataReader sdr=cmd.ExecuteScalar();
this.title.Text=sdr["proName"].tostring; //title是一个label
sdr.Close();
con.Close();这段代码哪里错了?请帮帮我啊
解决方案 »
- IE8 下fck出错
- 怎样调用函数返回的值??
- |M| 我写的一个省份和城市列表 大家看看有没有更好的加法
- GridView 动态绑定数据后,分页失败的问题!
- Asp.net能否将student表的男生记录产生到一个新表man存放?
- DataGrid控件中有几个模板列,每个模板列中有一个文本框控件,如果实现其中一个文本框获取焦点,让当前行的背景色变色.谢谢~
- 请教问题,数据来源
- ASP.NET做的页面如何与C++做的系统做对接
- 请问大家现在这个模式的创业是否有机会?
- windows 2003 IIS6 ASP.NET操作文件夹无效
- 如何产生不连续的ID索引
- 如何关闭excel进程?需要在DCOMCNFG中做什么配置吗?100分送上
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
string sdr=cmd.ExecuteScalar();
this.title.Text=sdr.ToString(); //title是一个labelcon.Close();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
string sdr=cmd.ExecuteScalar().ToString();//刚才这没有改
this.title.Text=sdr.ToString(); //title是一个labelcon.Close();orSqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
SqlDataReader sdr=cmd.ExecuteReader();
if(sdr.Read())
{
this.title.Text=sdr["proName"].ToString(); //title是一个label
sdr.Close();
}con.Close();
con.Open();
SqlCommand cmd = new SqlCommand("select proName from province",con);
string sdr=cmd.ExecuteScalar();
this.title.Text=sdr.ToString(); //title是一个labelcon.Close();
无法将object隐式转换为str??