var TableList:TStrings; ADoConnection:TADoConnection; begin ADoConnection:=TADoConnection.Create(nil); TableList:=TStringlist.Create; adoConnection.GetTableNames(TableList,true) if Tablelist.IndexOf(TableName)=-1 then 表不存在
怎么不行呀?请问TStrings的控件在哪呀?
var tbnames:tstringlist; ADoConnection1:TADoConnection; begin ADoConnection1:=TADoConnection.Create(nil); tbnames:=tstringlist.Create ; ADOConnection1.GetTableNames(tbnames,false); ListBox1.Items:=tbnames; adoConnection.GetTableNames(TableList,true) if Tablelist.IndexOf(TableName)=-1 then 表不存在 end.
“Project Booke.exe raised exception class EOleException with message '[Microsoft][ODBC驱动程序管理器]未发现数据源名称并且未指定默认驱动程序'.Process stopped.use step or run to continue”使用了“ dickeybird888(于伟刚) ”大侠给的提示出现了上面的错误,请问是什么原因呀?还有var里的变量加在哪呀?
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, ExtCtrls, StdCtrls;type TForm1 = class(TForm) ComboBox1: TComboBox; Image1: TImage; ADOConnection1: TADOConnection; procedure FormShow(Sender: TObject); procedure Image1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject); begin adoconnection1.GetTableNames(combobox1.Items,true); end;procedure TForm1.Image1Click(Sender: TObject); begin if combobox1.Items.IndexOf(combobox1.Text)=-1 then combobox1.Text:='所查的表不存在!'; end;end.
ADoConnection:TADoConnection;
begin
ADoConnection:=TADoConnection.Create(nil);
TableList:=TStringlist.Create;
adoConnection.GetTableNames(TableList,true)
if Tablelist.IndexOf(TableName)=-1 then
表不存在
tbnames:tstringlist;
ADoConnection1:TADoConnection;
begin
ADoConnection1:=TADoConnection.Create(nil);
tbnames:=tstringlist.Create ;
ADOConnection1.GetTableNames(tbnames,false);
ListBox1.Items:=tbnames;
adoConnection.GetTableNames(TableList,true)
if Tablelist.IndexOf(TableName)=-1 then
表不存在
end.
try
//ado.open
except
如果出错,可能是数据库里面没表了!!
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Image1: TImage;
ADOConnection1: TADOConnection;
procedure FormShow(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
begin
adoconnection1.GetTableNames(combobox1.Items,true);
end;procedure TForm1.Image1Click(Sender: TObject);
begin
if combobox1.Items.IndexOf(combobox1.Text)=-1 then
combobox1.Text:='所查的表不存在!';
end;end.