asp.net +c#+sql2000
错误发生在记录更新的时候,
错误提示为:
: 第 1 行: '=' 附近有语法错误。源错误:
行 90: SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);//这一行提示错误:
行 91: Cmd_webedit.Connection.Open();
行 92: Cmd_webedit.ExecuteNonQuery();
行 93: Cmd_webedit.Connection.Close(); 部分源代码如下:
在Page_Load里已经初始化
public string sid;//获得记录id号, Taxis.Text= editinformation["Taxis"].ToString();//获得更新记录的数据sid=Request.Params["showid"];
//点击更新按钮的函数
public void editinfomation(object Source, EventArgs e)
{
SqlConnection Con = new SqlConnection("Data Source=HELLO;Initial Catalog=Digital;User ID=sa;Pwd=;");
string sql_webedit="update webdata set Taxis='"+Taxis.Text+"' where ID="+sid;
SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);
Cmd_webedit.Connection.Open();
Cmd_webedit.ExecuteNonQuery();
Cmd_webedit.Connection.Close();
Response.Redirect("webmanager.aspx") ;
}请大家指教!!!!!!!!!!!
错误发生在记录更新的时候,
错误提示为:
: 第 1 行: '=' 附近有语法错误。源错误:
行 90: SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);//这一行提示错误:
行 91: Cmd_webedit.Connection.Open();
行 92: Cmd_webedit.ExecuteNonQuery();
行 93: Cmd_webedit.Connection.Close(); 部分源代码如下:
在Page_Load里已经初始化
public string sid;//获得记录id号, Taxis.Text= editinformation["Taxis"].ToString();//获得更新记录的数据sid=Request.Params["showid"];
//点击更新按钮的函数
public void editinfomation(object Source, EventArgs e)
{
SqlConnection Con = new SqlConnection("Data Source=HELLO;Initial Catalog=Digital;User ID=sa;Pwd=;");
string sql_webedit="update webdata set Taxis='"+Taxis.Text+"' where ID="+sid;
SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);
Cmd_webedit.Connection.Open();
Cmd_webedit.ExecuteNonQuery();
Cmd_webedit.Connection.Close();
Response.Redirect("webmanager.aspx") ;
}请大家指教!!!!!!!!!!!
你使用这个方法查看sql_webedit具体的代码:
public void editinfomation(object Source, EventArgs e)
{
SqlConnection Con = new SqlConnection("Data Source=HELLO;Initial Catalog=Digital;User ID=sa;Pwd=;");
string sql_webedit="update webdata set Taxis='"+Taxis.Text+"' where ID="+sid;Response.Write(sql_webedit);//在这里查看sql语句
//SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);
//Cmd_webedit.Connection.Open();
//Cmd_webedit.ExecuteNonQuery();
//Cmd_webedit.Connection.Close();
//Response.Redirect("webmanager.aspx") ;
}另外你这句代码的使用方法不是一个好的习惯:
sid=Request.Params["showid"];最好这样使用:
if(!Object.ReferenceEquals(Request.QueryString["Chapter"],null))
{
//do some thing
}
else
{
return;
}
把string 变为float 型;拜托大家拉
Cmd_webedit.Connection.Open();
Cmd_webedit.ExecuteNonQuery();
Cmd_webedit.Connection.Close();Response.Redirect("webmanager.aspx") ;
改为Response.Write(sql_webedit);
然后把输出的在sql执行一下看看。
--------------------
语句没有问题,估计是接收到的参数有问题。
加一句
response.write(sql_webedit);
response.end();
输出SQL语句,拿到数据库中运行
不能自动完成,用什么函数,谢了
Convert 没 toFloat() 方法;