InterBase的varchar问题

saxash 2003-11-17 02:09:54
表 A
create table A
(
S varchar(10)
)

程序 Button1, Edit1, Edit2, InterBase连接
procedure TForm1.Button1Click(Sender: TObject);
begin
if Edit1.Text <> '' then
begin
Edit2.Text := Edit1.Text + ' '; //Edit2 多2个空格
with IBQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' insert into a (s) values(:s)');
ParamByName('s').AsString := Edit1.Text;
ExecSQL;

Close;
SQL.Clear;
SQL.Add(' select * from A where s = :s');
ParamByName('s').AsString := Edit2.Text;
Open;
if RecordCount > 0 then
ShowMessage('一样!')
else
ShowMessage('不同!');
end;
end;
end;

结果是‘一样!’!...InterBase的varchar有没有空格都一样吗?怎么改呢?
...全文
35 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
耙子 2003-11-20
  • 打赏
  • 举报
回复
char 和 varchar 在IB里面都一样作为 varchar存储,传输的时候从IB 7x开始截取尾部的空格,到了客户端,如果是char 再补全,提高传输效率。

你能否考虑用拳脚空格,或者结尾不要使用空格
saxash 2003-11-20
  • 打赏
  • 举报
回复
...
saxash 2003-11-18
  • 打赏
  • 举报
回复
........
saxash 2003-11-17
  • 打赏
  • 举报
回复
如果要区分呢?
saxash 2003-11-17
  • 打赏
  • 举报
回复
如果想在表里分别存入 'a' 和 'a '怎么办啊?
angle097113 2003-11-17
  • 打赏
  • 举报
回复
在你查询数据的时候它是不管你的数据的后面有没有空格的
例如你的数据是'aa '
你查询'aa'和 'aa '都能够查询的到的
saxash 2003-11-17
  • 打赏
  • 举报
回复
用 char 也是一样的啊!
metro 2003-11-17
  • 打赏
  • 举报
回复
非要加空格吗?用其它符号不行吗?
meteorlg 2003-11-17
  • 打赏
  • 举报
回复
改用char

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧