» 首页 » 电脑_数码 » 编程 » 我的Delphi学生管理系统在检测的时候没问题,但是在运行...

我的Delphi学生管理系统在检测的时候没问题,但是在运行...

在运行“查询”之后,就出现如下:
project project1.exe raised exception class EOleException with message 'FROM 子句语法错误。'. process stopped. use step or run to continue.


我把我的查询信息代码发下:(麻烦大家看看哪里有错误。谢谢哦。)

unit FView;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DBCtrls, Grids, DBGrids, DB, ComCtrls, ADODB;

治疗省略那些。。(字数太多发不了问题=。=)
var
FView1: TFView1;

implementation

{$R *.dfm}

uses FMain;

procedure TFView1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;

procedure TFView1.SpeedButton1Click(Sender: TObject);
begin
listbox1.Items.Add(DBLookuplistbox1.selectedItem);
end;

procedure TFView1.SpeedButton2DblClick(Sender: TObject);
begin
listbox1.items.Delete(listbox1.ItemIndex);
end;

procedure TFView1.BitBtn1Click(Sender: TObject);
var n,i:integer;
sqlstr:string;
begin
sqlstr:='SELECT * FROM stuinfo';
n:=listbox1.Items.Count - 1;
if n>=0 then
begin
sqlstr:=sqlstr+'WHERE(省份='''+listbox1.Items[0]+''')';
i:=1;
while i<n do
begin
sqlstr:=sqlstr+'OR(省份='''+listbox1.Items[i]+''')';
i:=i+1;
end;
end;
sqlstr:=sqlstr+';';
memo1.Lines.add(sqlstr);
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sqlstr);
ADOQuery1.Open;
end;

procedure TFView1.DBLookupListBox3Click(Sender: TObject);
begin
edit1.Text:=DBLookuplistbox2.SelectedItem;
end;

procedure TFView1.DBLookupListBox2Click(Sender: TObject);
begin
edit2.Text:=DBLookuplistbox3.SelectedItem;
end;

procedure TFView1.BitBtn2Click(Sender: TObject);
var sqlstr:string;
begin
sqlstr:='SELECT * FROM stuinfo';
if (edit1.Text='') and (edit2.Text='') then
begin
sqlstr:=sqlstr+';';
if combobox1.Text<>'' then combobox1.Text:='';
end;

if (edit1.Text<>'')and(edit2.Text<>'') then
begin
if combobox1.Text='' then combobox1.Text:='or';
sqlstr:=sqlstr+'WHERE 省份 LIKE ''%'+edit1.Text+'%''';
sqlstr:=sqlstr+' '+combobox1.Text;
sqlstr:=sqlstr+' 姓名 LIKE ''%'+edit2.Text+'%'';';
end;

if (edit1.Text<>'')and(edit2.Text='') then
begin
if combobox1.Text<>'' then combobox1.Text:='';
sqlstr:=sqlstr+'WHERE 省份 LIKE ''%'+edit1.Text+'%'';';
end;

if (edit1.Text='')and(edit2.Text<>'') then
begin
if combobox1.Text<>'' then combobox1.Text:='';
sqlstr:=sqlstr+' WHERE 姓名 LIKE ''%'+edit2.Text+'%'';';
end;
memo1.Lines.Add(sqlstr);
ADOQuery1.SQL.clear;
ADOQuery1.SQL.add(sqlstr);
ADOQuery1.Open;
end;


end.


既然提示你from子句出问题了,那一般是你的sql语句出错了,建议调试时先把整个sql语句打印出来,把结果复制到查询分析器里运行,这样方便你找出错误原因。
既然提示你from子句出问题了,那一般是你的sql语句出错了,建议调试时先把整个sql语句打印出来,把结果复制到查询分析器里运行,这样方便你找出错误原因。

 相关问题
·我的Delphi学生管理系统在检测的时候没问题,但是在运行...
·请高手帮忙优化一下这条SQL语句
·在fortran中rand()的用法是怎样的?麻烦举个例子
·一、以下程序包含三个函数:sort,print,printfil,按照要...
·求一个批处理~!!
·求简单的php通用后台程序?
·在Textl中输入的任何字符,立即显示在Text2中。
·编写一类似QQ群聊的多人聊天程序
·请教这段是什么意思.
·关于学习asp.net
·pascal题目:机器人
·什么是动漫知识与动漫语言?
·输入2个字符串,输出较大的一个
·急!!!根据用户的ID调数据库中的内容显示
·判断字符个数及读取字段程序

 《我的Delphi学生管理系统在检测的时候没问题,但是在运行...》答案收集时间:2008-06-14 14:28:21



©2007 电脑技术问答录