在ASP.NET,数据库ORACLE的环境
配置SQLDATASOURCE自定义WHERE 条件的时候 LIKE怎么写的?下面的格式老提示
- C# code
if (txtDescription.Text != "") { sdsSrhCases.SelectParameters.Add("Description", txtDescription.Text); sqlWhere += " AND Description like ('%' + :Description + '%')"; } sdsSrhCases.SelectCommand += sqlWhere; gvSrhCaseRec.DataBind();
+ $exception {"ORA-01722: 无效数字\n"} System.Exception {System.Data.OracleClient.OracleException}
+ this {ASP.memberpages_operm_case_srhcaserec_aspx} MemberPages_OperM_Case_SrhCaseRec {ASP.memberpages_operm_case_srhcaserec_aspx}
+ sender {Text = "故障查找"} object {System.Web.UI.WebControls.Button}
+ e {System.EventArgs} System.EventArgs
sqlWhere " WHERE DEPTID = :DeptId AND Description like ('%' + :Description + '%') ORDER BY ACTDATE DESC" string
------解决方案--------------------------------------------------------
- C# code
if (txtDescription.Text != "") { sdsSrhCases.SelectParameters.Add("Description", txtDescription.Text); sqlWhere += " AND Description like" + "'" +strGame+ "%'" } sdsSrhCases.SelectCommand += sqlWhere; gvSrhCaseRec.DataBind();
------解决方案--------------------------------------------------------
楼主要注意""号啊。。。是在不行你用个LABEL显示你的SQL语句出来,然后用数据库测试下,,先注释掉操作数据库语句那部分
------解决方案--------------------------------------------------------
if (txtDescription.Text != "")
{
sdsSrhCases.SelectParameters.Add("Description", txtDescription.Text);
sqlWhere += " AND Description like ('%:Description%')";
}
sdsSrhCases.SelectCommand += sqlWhere;
gvSrhCaseRec.DataBind();
------解决方案--------------------------------------------------------
- C# code
if (txtDescription.Text != "") { sdsSrhCases.SelectParameters.Add("@Description", txtDescription.Text); sqlWhere += " AND Description like ('%' + @Description + '%')"; }
------解决方案--------------------------------------------------------
可能操作符不一样,你往控件里手动加个参数,看看生成的代码是怎么写的,COPY下好了
------解决方案--------------------------------------------------------
检查你的数据,DESCRIPTION给了多少,把这个SQL拷到ORACLE里面去测试下
------解决方案--------------------------------------------------------
你用个LABEL显示你的SQL语句出来,然后用数据库测试下。。。
------解决方案--------------------------------------------------------
oracle语法的LIKE是这么用的么?查查看呢,我怎么觉得好像是?不是%
------解决方案--------------------------------------------------------
- C# code
if (txtDescription.Text != "") { sdsSrhCases.SelectParameters.Add(":Description", txtDescription.Text); sqlWhere += " AND Description like ('%' + :Description + '%')"; } sdsSrhCases.SelectCommand += sqlWhere; gvSrhCaseRec.DataBind();
------解决方案--------------------------------------------------------
sqlWhere += " AND Description like '%" + :Description + "%'";
or
sqlWhere += " AND Description like '%:Description%'";