| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1396 人关注过本帖
标题:[求助]表达式包含无效的字符串常量!!
只看楼主 加入收藏
huanying205
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2007-6-14
收藏
 问题点数:0 回复次数:2 
[求助]表达式包含无效的字符串常量!!

我想把符合条件的记录显示到DataGirdView控件上,代码是这么写得:
string strRowFilter = "";
string strCmb = this.comboBox1.Text.Trim();
if (this.TextBox1.Text.Trim() != "")
strRowFilter += "序号 like '%" + TextBox1.Text.Trim() + "%'and";
if (this.TextBox2.Trim() != "")
strRowFilter += "姓名 like '" + TextBox2.Text.Trim() + "' and";
if (strCmb != "")
strRowFilter += "籍贯 like '" + strCmb + "' and ";
if (strRowFilter != "")
strRowFilter = strRowFilter.Substring(0, strRowFilter.Length - 5);
tempTable.DefaultView.RowFilter = strRowFilter;
如果在序号的文本框里输入数字后,运行结果就提示说:表达式包含无效的字符串常量:“序号”
输入姓名和籍贯也是一样,请教一下 这是怎么回事呀?

搜索更多相关主题的帖子: 常量 字符 表达 
2007-10-09 10:28
huanying205
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2007-6-14
收藏
得分:0 
没有指点一下吗?
2007-10-09 10:58
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
string strRowFilter = "select * from tablename where 1=1 ";
string strCmb = this.comboBox1.Text.Trim();
if (this.TextBox1.Text.Trim() != "")
strRowFilter += " and 序号 like '%" + TextBox1.Text.Trim() + "%'";
if (this.TextBox2.Trim() != "")
strRowFilter += " and 姓名 like '" + TextBox2.Text.Trim() + "'";
if (strCmb != "")
strRowFilter += " and 籍贯 like '" + strCmb + "'";

飘过~~
2007-10-09 12:37
快速回复:[求助]表达式包含无效的字符串常量!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015022 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved