D
delphinewboy
Unregistered / Unconfirmed
GUEST, unregistred user!
帮我看一下,系统数据库连接成功了,但是我在操作时他说我语法错误,
我就不知道错那了,请各位帮忙
提示的错误信{Project Projectaa.exe.raised exception class EoleException.with message.[Microsoft]
[ODBC DBase Driver] syntax error.in FROM.Clause process stopped.Use Step or Run to continue.}
我的程序如下:
procedure TForm1.BitBtn1Click(Sender: TObject);
var together,key:string;
begin
table:=combobox1.text;
together:='';
combobox2.text:=combobox2.Items[combobox2.itemindex];
key:=combobox2.Text;
if edit1.Text=''
then
begin
showmessage('请输入字段值以便查询');
edit1.setfocus;
end
else
begin
ADoQuery1.close;
AdoQuery1.SQL.Clear;
AdoQuery1.Sql.Add('select * from ' +Table+ ' where ' + key +' like "%'+edit1.Text+'%"');
AdoQuery1.open;
if AdoQuery1.RecordCount=0 then
MessageDlg('没有你要的记录',mtinformation,[mbok],0);
panel3.visible:=true;
Dbgrid1.visible:=true;
DBNavigator1.visible:=true;
panel4.visible:=false;
Dbgrid2.visible:=false;
DBNavigator2.visible:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var iCount,j:integer;
tables:Tstringlist;
begin
try
tables:=Tstringlist.create;
Adoconnection1.GetTableNames(tables,false);
for j:=0 to tables.count-1 do
combobox1.Items.add(tables.strings[j]);
finally
tables.free;
combobox1.itemindex:=0;
combobox1.Text:=combobox1.items[combobox1.itemindex];
table:=combobox1.text;
ADoQuery1.close;
ADoQuery1.sql.clear;
AdoQuery1.sql.add('select * from '+table);
AdoQuery1.open;
Groupbox1.caption:=table+'数据表内';
GroupBox2.caption:='根据企业名称查询'+table+'表:';
ADoDatasET1.Close;
AdoDataset1.CommandText:='';
ADoDataset1.commandText:='select * from '+Table;
AdoDataset1.open;
Combobox2.items.clear;
for icount:=0 to AdoDataSet1.Fields.count-1 do
begin
Combobox2.items.add(AdoDataset1.fields[icount].Fieldname);
end;
combobox2.itemindex:=0;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var icount:integer;
begin
combobox1.text:=combobox1.Items[combobox1.itemindex];
table:=combobox1.Text;
ADoQuery1.close;
ADoQuery1.sql.clear;
AdoQuery1.sql.add('select * from '+table);
AdoQuery1.open;
Groupbox1.caption:=table+'数据表内';
GroupBox2.caption:='根据企业名称查询'+table+'表:';
ADoDatasET1.Close;
AdoDataset1.CommandText:='';
ADoDataset1.commandText:='select * from '+Table;
AdoDataset1.open;
Combobox2.items.clear;
for icount:=0 to AdoDataSet1.Fields.count-1 do
begin
Combobox2.items.add(AdoDataset1.fields[icount].Fieldname);
end;
combobox2.itemindex:=0;
panel3.visible:=true;
Dbgrid1.visible:=true;
DBNavigator1.visible:=true;
panel4.visible:=false;
Dbgrid2.visible:=false;
DBNavigator2.visible:=false;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var keyy,where:string;
begin
table:=combobox1.text;
if edit2.text='' then
begin
showmessage('请输入企业名称以便查询');
edit2.setfocus;
end
else
begin
keyy:=edit2.text;
if table='animals' then
begin
messagedlg('不能在animals数据表内查找相关的企业名称'+#13+'请另选别的数据表',mtinformation,[mbok],0);
PageControl1.ActivePageIndex:=0;
end
else begin
where:='select DISTINCT *,animals.name,animals.size from '+Table+',animals where animals.weight'+' like "%'+keyy+'%"';
where:=where+' and '+Table+'.企业名称 ="'+keyy+'"';
//where:='select * from 案卷,'+Table+' where 案卷.卷号'+'='+Table+'.'+keyy;
//where:='select * from '+Table+' where '+table+'.卷号'+' like "%'+keyy+'%"';
AdoQuery2.Close;
AdoQuery2.sql.Clear;
AdoQuery2.sql.add(where);
AdoQuery2.open;
if AdoQuery2.RecordCount=0 then
MessageDlg('没有你要的记录',mtinformation,[mbok],0);
panel4.visible:=true;
Dbgrid2.visible:=true;
DBNavigator2.visible:=true;
panel3.visible:=false;
Dbgrid1.visible:=false;
DBNavigator1.visible:=false;
end;
end;
end;
procedure TForm1.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
var API:integer;
begin
API:=pageControl1.ActivePageIndex;
case API of
1:edit1.text:='';
2:edit2.text:='';
end;
end;
end.
还有就是我用adoquery连接我自己的数据库时连接成功,但是在执行时却连不上了,是怎么一回
事呀,我用的是delphi自带的paradox 别名dbdemo,各位一定要帮小弟一把呀。要是有愿意帮小
弟的请多多联系qq:12316730 在些小弟有礼了!
我就不知道错那了,请各位帮忙
提示的错误信{Project Projectaa.exe.raised exception class EoleException.with message.[Microsoft]
[ODBC DBase Driver] syntax error.in FROM.Clause process stopped.Use Step or Run to continue.}
我的程序如下:
procedure TForm1.BitBtn1Click(Sender: TObject);
var together,key:string;
begin
table:=combobox1.text;
together:='';
combobox2.text:=combobox2.Items[combobox2.itemindex];
key:=combobox2.Text;
if edit1.Text=''
then
begin
showmessage('请输入字段值以便查询');
edit1.setfocus;
end
else
begin
ADoQuery1.close;
AdoQuery1.SQL.Clear;
AdoQuery1.Sql.Add('select * from ' +Table+ ' where ' + key +' like "%'+edit1.Text+'%"');
AdoQuery1.open;
if AdoQuery1.RecordCount=0 then
MessageDlg('没有你要的记录',mtinformation,[mbok],0);
panel3.visible:=true;
Dbgrid1.visible:=true;
DBNavigator1.visible:=true;
panel4.visible:=false;
Dbgrid2.visible:=false;
DBNavigator2.visible:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var iCount,j:integer;
tables:Tstringlist;
begin
try
tables:=Tstringlist.create;
Adoconnection1.GetTableNames(tables,false);
for j:=0 to tables.count-1 do
combobox1.Items.add(tables.strings[j]);
finally
tables.free;
combobox1.itemindex:=0;
combobox1.Text:=combobox1.items[combobox1.itemindex];
table:=combobox1.text;
ADoQuery1.close;
ADoQuery1.sql.clear;
AdoQuery1.sql.add('select * from '+table);
AdoQuery1.open;
Groupbox1.caption:=table+'数据表内';
GroupBox2.caption:='根据企业名称查询'+table+'表:';
ADoDatasET1.Close;
AdoDataset1.CommandText:='';
ADoDataset1.commandText:='select * from '+Table;
AdoDataset1.open;
Combobox2.items.clear;
for icount:=0 to AdoDataSet1.Fields.count-1 do
begin
Combobox2.items.add(AdoDataset1.fields[icount].Fieldname);
end;
combobox2.itemindex:=0;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var icount:integer;
begin
combobox1.text:=combobox1.Items[combobox1.itemindex];
table:=combobox1.Text;
ADoQuery1.close;
ADoQuery1.sql.clear;
AdoQuery1.sql.add('select * from '+table);
AdoQuery1.open;
Groupbox1.caption:=table+'数据表内';
GroupBox2.caption:='根据企业名称查询'+table+'表:';
ADoDatasET1.Close;
AdoDataset1.CommandText:='';
ADoDataset1.commandText:='select * from '+Table;
AdoDataset1.open;
Combobox2.items.clear;
for icount:=0 to AdoDataSet1.Fields.count-1 do
begin
Combobox2.items.add(AdoDataset1.fields[icount].Fieldname);
end;
combobox2.itemindex:=0;
panel3.visible:=true;
Dbgrid1.visible:=true;
DBNavigator1.visible:=true;
panel4.visible:=false;
Dbgrid2.visible:=false;
DBNavigator2.visible:=false;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var keyy,where:string;
begin
table:=combobox1.text;
if edit2.text='' then
begin
showmessage('请输入企业名称以便查询');
edit2.setfocus;
end
else
begin
keyy:=edit2.text;
if table='animals' then
begin
messagedlg('不能在animals数据表内查找相关的企业名称'+#13+'请另选别的数据表',mtinformation,[mbok],0);
PageControl1.ActivePageIndex:=0;
end
else begin
where:='select DISTINCT *,animals.name,animals.size from '+Table+',animals where animals.weight'+' like "%'+keyy+'%"';
where:=where+' and '+Table+'.企业名称 ="'+keyy+'"';
//where:='select * from 案卷,'+Table+' where 案卷.卷号'+'='+Table+'.'+keyy;
//where:='select * from '+Table+' where '+table+'.卷号'+' like "%'+keyy+'%"';
AdoQuery2.Close;
AdoQuery2.sql.Clear;
AdoQuery2.sql.add(where);
AdoQuery2.open;
if AdoQuery2.RecordCount=0 then
MessageDlg('没有你要的记录',mtinformation,[mbok],0);
panel4.visible:=true;
Dbgrid2.visible:=true;
DBNavigator2.visible:=true;
panel3.visible:=false;
Dbgrid1.visible:=false;
DBNavigator1.visible:=false;
end;
end;
end;
procedure TForm1.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
var API:integer;
begin
API:=pageControl1.ActivePageIndex;
case API of
1:edit1.text:='';
2:edit2.text:='';
end;
end;
end.
还有就是我用adoquery连接我自己的数据库时连接成功,但是在执行时却连不上了,是怎么一回
事呀,我用的是delphi自带的paradox 别名dbdemo,各位一定要帮小弟一把呀。要是有愿意帮小
弟的请多多联系qq:12316730 在些小弟有礼了!