delphi中查询语句

来源:百度知道 编辑:UC知道 时间:2024/05/12 06:53:09
select * from loginInfo where username= Edint1.Text
这句在DELPHI中应该怎么写?
我写成sql='select * from loginInfo where username=''+Edit1.Text+''';
不对,他把Edit1.Text也给当字符了,还想问一下delphi中的if可以加begin,end吗?
我想表达的意思就是一个嵌套,比如
if 条件
begin
语句
if 条件
语句
else
语句
else
语句
end;
还有,这中间可以加分号吗?是不是if中不可以加分号?否则就结束了?
我SQL语句中用的全是单引号

应该这样:

if 条件 then
begin
  语句;
  if 条件
  then 语句
  else 语句
end;

原则:if之后必须有then,可以选择有else,但是else前面不能有分号

sql='select * from loginInfo where username=''+Edit1.Text+''';
应该修改为:
sql='select * from loginInfo where username="'+Edit1.Text+'"';