在sql数据库中:
数据库名:sq_ha315a
表名:shop
shop表里的需要用到的字段:Expr4,vclassname在mysql数据库中:
数据库名:phpwind
表名:pw_threads
pw_threads表里的需要用到的字段:author,bigType两张表的关系shop.Expr4=pw_threads.author要求:根据(shop.Expr4=pw_threads.author)将shop.vclassname
的值更新到pw_threads.bigType
我做了如下测试,报错如下:错误
当前上下文中不存在名称“Expr41”
当前上下文中不存在名称“vclassname1”
请高手帮我看看!
SqlCommand com;
SqlDataReader dr;
SqlConnection myconn = new SqlConnection("Data Source=localhost;" + "Initial Catalog=sq_ha315a;" + "User ID=sa;Pwd=wawy593580393");
myconn.Open();
com = new SqlCommand("select Expr4,vclassname from shop", myconn);
dr = com.ExecuteReader();
while (dr.Read())
{
Expr41 = dr["Expr4"].ToString();
vclassname1 = dr["vclassname"].ToString();
MySqlConnection sqlconn = new MySqlConnection("Data Source=localhost;" + "Initial Catalog=phpwind;" + "User ID=root;Pwd=");
sqlconn.Open();
string sql = string.Format("update pw_threads set bigType=vclassname where Expr4=Expr4");
MySqlCommand sqlcom = new MySqlCommand(sql, sqlconn);
sqlcom.ExecuteNonQuery();
sqlconn.Close();
}
数据库名:sq_ha315a
表名:shop
shop表里的需要用到的字段:Expr4,vclassname在mysql数据库中:
数据库名:phpwind
表名:pw_threads
pw_threads表里的需要用到的字段:author,bigType两张表的关系shop.Expr4=pw_threads.author要求:根据(shop.Expr4=pw_threads.author)将shop.vclassname
的值更新到pw_threads.bigType
我做了如下测试,报错如下:错误
当前上下文中不存在名称“Expr41”
当前上下文中不存在名称“vclassname1”
请高手帮我看看!
SqlCommand com;
SqlDataReader dr;
SqlConnection myconn = new SqlConnection("Data Source=localhost;" + "Initial Catalog=sq_ha315a;" + "User ID=sa;Pwd=wawy593580393");
myconn.Open();
com = new SqlCommand("select Expr4,vclassname from shop", myconn);
dr = com.ExecuteReader();
while (dr.Read())
{
Expr41 = dr["Expr4"].ToString();
vclassname1 = dr["vclassname"].ToString();
MySqlConnection sqlconn = new MySqlConnection("Data Source=localhost;" + "Initial Catalog=phpwind;" + "User ID=root;Pwd=");
sqlconn.Open();
string sql = string.Format("update pw_threads set bigType=vclassname where Expr4=Expr4");
MySqlCommand sqlcom = new MySqlCommand(sql, sqlconn);
sqlcom.ExecuteNonQuery();
sqlconn.Close();
}
解决方案 »
- 如何调用ascx里datalist里的控件
- 请问:"光棍网"取一个什么样的域名比较好?
- 关于Sql查询,存储过程,评论
- sqlparameter的问题请各位帮助看一下
- 利用SqlCommandBuilder.Update()可以产生更新数据库的操作,它与储存过程相比,有何优缺点?
- 急求教关于DropDownlist控件的数据绑定问题◆◇◆◇
- 如何设置RegularExpressionValidator关于日期的正则表达式?
- 页面控件解析 - 求助
- 关于vs2012的问题,请教一下!
- radiobutton如何用?
- 请问怎样打开本地文件浏览器(Windows Explorer)? 不是服务器端的。
- asp:DropDownList如何载入一数据表(sql2005)一字段所有值?C#代码如何写?
string sql = string.Format("update pw_threads set bigType='"+vclassname+"' where Expr4='"+Expr4+"'");