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.   

    估计是 sql_webedit的错误
    你使用这个方法查看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;
    }
      

  2.   

    说明:Texis 在数据库中是float 型,如果不改变数据库的Texis的数据类型,那怎么在更新的时候
    把string 变为float 型;拜托大家拉
      

  3.   

    估计是sql语句未通过,先去掉SqlCommand Cmd_webedit=new SqlCommand(sql_webedit,Con);
    Cmd_webedit.Connection.Open();
    Cmd_webedit.ExecuteNonQuery();
    Cmd_webedit.Connection.Close();Response.Redirect("webmanager.aspx") ;
    改为Response.Write(sql_webedit);
    然后把输出的在sql执行一下看看。
      

  4.   

    接受的参数可以转换float再使用啊。
      

  5.   

    sid取到值了没有.把SQL语句输出一看就知道错在那了
      

  6.   

    string sql_webedit="update webdata set Taxis='"+Taxis.Text+"' where ID="+sid;
    --------------------
    语句没有问题,估计是接收到的参数有问题。
    加一句
    response.write(sql_webedit);
    response.end();
    输出SQL语句,拿到数据库中运行
      

  7.   

    怎么用Textbox.Text.Tostring()转换成float啊,C#
    不能自动完成,用什么函数,谢了
      

  8.   

    Convert.toDouble(Taxis.Text);
    Convert 没 toFloat() 方法;