帮忙看看数据库无法更新的问题。我试了好久都没成功。 你将drl.Close();写到while(drl.Read()){}外面试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 还有myConnection.Close();myConnection.Dispose();都写到外面 哇赛!这么多的代码阿看的我都晕了!就是 yqdeng(享受生活每一天) 说的那样 while(dr1.Read()){ int sscount = Int32.Parse(dr1["sfromcount"].ToString());int ssscount=sscount;dr1.Close();int countnumber1=ssscount+1;string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection);myCommand1.ExecuteNonQuery();myConnection.Close();myConnection.Dispose(); }dr1.Read() 时,你执行dr1.Close();myConnection.Close();myConnection.Dispose();?????? 1,string execString = "select sfromcount from mobilenumber where number='"+numbers+"'"; //number字段是数字还是字符,如果是数字就不要加单引号。2,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; //stime是什么类型,参看number说明。3,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; //加到myConnection.Open();之前。4,try //看看什么错。{ myCommand1.ExecuteNonQuery();}catch{Exception ex}{ MessageBox.Show(ex.Message)} 把你的while循环改成如下:int sscount =-1;if(dr1.Read()){ sscount=Int32.Parse(dr1["sfromcount"].ToString());}dr1.Close();if(sscount>0){ int ssscount=sscount; int countnumber1=ssscount+1; string sSqlCommand1="update mobilenumber set stime='" +timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection); myCommand1.ExecuteNonQuery();}myConnection.Close();myConnection.Dispose(); 求vs2010 MVC2 网站开发教程 讨论一个C#与DELPHI的应用问题!~~高手请进~~! 关于[Application Name].vshost.exe COM 对象与其基础 RCW 分开后就不能再使用?? 大家来说一下p2p搜索 [请问]怎样用Math类 打开解决方案时,出现“vs.net无法创建或打开应用程序,问题是因为本地的WEB服务器上没有安装所需的组件。请运行VS.NET安装程序,并添加W VS2010无法启动项目 一个关于数据填加的问题! 如何让winform窗口显示最小化,最大化按钮,不显示关闭按钮? Help!!!!!! 请问几个asp.net问题
myConnection.Close();
myConnection.Dispose();
都写到外面
这么多的代码阿
看的我都晕了!
就是 yqdeng(享受生活每一天) 说的那样
{
int sscount = Int32.Parse(dr1["sfromcount"].ToString());
int ssscount=sscount;
dr1.Close();
int countnumber1=ssscount+1;
string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'";
SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection);
myCommand1.ExecuteNonQuery();
myConnection.Close();
myConnection.Dispose(); }dr1.Read() 时,你执行dr1.Close();
myConnection.Close();
myConnection.Dispose();????
??
2,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; //stime是什么类型,参看number说明。
3,string sSqlCommand1="update mobilenumber set stime='"+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'"; //加到myConnection.Open();之前。
4,try //看看什么错。
{
myCommand1.ExecuteNonQuery();
}
catch{Exception ex}
{
MessageBox.Show(ex.Message)
}
int sscount =-1;
if(dr1.Read())
{
sscount=Int32.Parse(dr1["sfromcount"].ToString());
}
dr1.Close();if(sscount>0)
{
int ssscount=sscount;
int countnumber1=ssscount+1;
string sSqlCommand1="update mobilenumber set stime='"
+timeTempString+"',sfromcount="+countnumber1+" where number='"+number1+"'";
SqlCommand myCommand1=new SqlCommand(sSqlCommand1,myConnection);
myCommand1.ExecuteNonQuery();
}
myConnection.Close();
myConnection.Dispose();