大家好!请各位帮小弟我看看SQL有错吗?运行时‘FROM子句语法异常’-----------

大家好!请各位帮我看看SQL有错吗?运行时‘FROM子句语法错误’-----------
相关代码如下:
if radiobutton1.Checked then
  begin
  sql:='select *from money where riqi='+''''+combobox1.Text+'''';
  end
  else if radiobutton2.Checked then
  begin
  sql:='select *from money where xiangmu='+''''+combobox2.Text+'''';
  end
  else if radiobutton3.Checked then
  begin
  sql:='select *from money where money='+''''+combobox3.Text+'''';
  end;

------解决方案--------------------
呵呵。。

没注意看,moeny 是 SQL的关键字,所以导致错误。
你换个名吧




------解决方案--------------------
if radiobutton1.Checked then 
sql:= 'select *from money1 where riqi= '+ ' ' ' '+combobox1.Text+ ' ' ' '
else if radiobutton2.Checked then 
sql:= 'select *from money1 where xiangmu= '+ ' ' ' '+combobox2.Text+ ' ' ' '
else if radiobutton3.Checked then 
sql:= 'select *from money1 where money= '+ ' ' ' '+combobox3.Text+ ' ' ' '; 
楼上的正确,确实是money的问题换成money1试试,另给你简化了一下句子,有太多的begin end了
------解决方案--------------------
Delphi(Pascal) code
if radiobutton1.Checked then 
      sql:= 'select * from money where riqi= '+ quotedstr(combobox1.Text)
      else if radiobutton2.Checked then 
          sql:= 'select * from money where xiangmu= '+ quotedstr(combobox1.Text)
             else if radiobutton3.Checked then 
                      sql:= 'select * from money where money= '+ quotedstr(combobox1.Text);

------解决方案--------------------
你的程序至少有以下错误
1、select *from 中*与from之间必须有空格,这是你出现“FROM子句语法错误”的直接原因
2、money是SQL系统关键字,必须用[]包括
3、如果money属于数值类型的字段,那么 combobox3.Text 部分不能用引号
4、combobox3.Text部分没有进行空值判断部分,假如combobox3.Text是空的,那么这条语句根本不是这么写
5、不算错误的错误,combobox1.Text部分应该用QuotedStr()否则如果combobox1.Text里面有单引号那就乱套了。


if radiobutton1.Checked then 
begin 
sql:= 'select * from [money] where riqi='+QuotedStr(combobox1.Text); 
end 
else if radiobutton2.Checked then 
begin 
sql:= 'select * from [money] where xiangmu='+QuotedStr(combobox2.Text); 
end 
else if radiobutton3.Checked then 
begin 
sql:= 'select * from [money] where [money]='+combobox3.Text; 
end;