String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i.ToString();

解决方案 »

  1.   

    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i;
      

  2.   

    应该这样写
    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID=" + i.tostring();
      

  3.   

    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID='"+i+"'";
      

  4.   

    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+d;
      

  5.   

    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID='"+d+"'";
      

  6.   

    string d = ddlProductFilter.SelectedValue;
    int i=(int)Convert.ChangeType(d,typeof(int));String strSQLcheck="select 模块名称 from 产品模块 where 产品ID={0}";
    string temp=string.format(strSqlcheck,i);
    SqlCommand cb2 = new SqlCommand(temp,objConnection2);
    一定行的:)
      

  7.   

    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i.ToString();把i放到字符串里就没有值了
      

  8.   

    ="select 模块名称 from 产品模块 where 产品ID="+i;
      

  9.   

    这和多人回答怎么没有人说用Sql参数的形式传参数呢,可以参考如下的用法哟:String strSQLcheck="select 模块名称 from 产品模块 where 产品ID=@ID";
    SqlParameter p=new SqlParameter("@ID",i);
    SqlCommand cb2 = new SqlCommand(strSQLcheck,objConnection2);
    cb2.Parameters.Add(p);
      

  10.   

    在SQL语句中,采用“数值变量”不加引号:string d = ddlProductFilter.SelectedValue;
                    
    string strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+d;
    SqlCommand cb2 = new SqlCommand(strSQLcheck,objConnection2);采用“字符串变量”必须加引号:string d = ddlProductFilter.SelectedValue;
                    
    string strSQLcheck="select 模块名称 from 产品模块 where 产品ID='"+d+"'";
    SqlCommand cb2 = new SqlCommand(strSQLcheck,objConnection2);以上两种方法取决于“产品ID”在SQL中的数据类型。
      

  11.   

    变量引用错了
    String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i+"";