String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i;
应该这样写 String strSQLcheck="select 模块名称 from 产品模块 where 产品ID=" + i.tostring();
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID='"+i+"'";
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+d;
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID='"+d+"'";
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); 一定行的:)
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i.ToString();把i放到字符串里就没有值了
="select 模块名称 from 产品模块 where 产品ID="+i;
这和多人回答怎么没有人说用Sql参数的形式传参数呢,可以参考如下的用法哟:String strSQLcheck="select 模块名称 from 产品模块 where 产品ID=@ID"; SqlParameter p=new SqlParameter("@ID",i); SqlCommand cb2 = new SqlCommand(strSQLcheck,objConnection2); cb2.Parameters.Add(p);
在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中的数据类型。
变量引用错了 String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i+"";
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID=" + i.tostring();
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);
一定行的:)
SqlParameter p=new SqlParameter("@ID",i);
SqlCommand cb2 = new SqlCommand(strSQLcheck,objConnection2);
cb2.Parameters.Add(p);
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中的数据类型。
String strSQLcheck="select 模块名称 from 产品模块 where 产品ID="+i+"";