P
PLWang
Unregistered / Unconfirmed
GUEST, unregistred user!
新手上路 试着用ADO编程 程序里用到ADOConnection ADOQuery 很简单的查询程序
代码:
procedure TForm1.BitBtn1Click(Sender: TObject);
var H:string;
begin
If Check(trim(Edit1.text)) then //Check Change自定义函数
begin
H:= Change(trim(Edit1.text));
ADOConnection1.Open;
ADOQuery1.Connection:= ADOConnection1;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from IP where IPStart like ''');
ADOQuery1.SQL.Add(H);
ADOQuery1.SQL.Add(''' and IPEnd like ''');
ADOQuery1.SQL.Add(H);
ADOQuery1.SQL.Add('''');
ADOQuery1.Open;
end
else showmessage('your input is not a illegle IP address!');
end;
ADOConnection字串:
Provider=MSDASQL.1;Persist Security Info=False;User ID=user;Mode=Read|Share Deny Write;
Extended Properties="DSN=MS Access 97 Database;DBQ=D:/CPP/NEWDB/IP.mdb;
DriverId=281;FIL=MS Access;
FILEDSN=C:/Program Files/Common Files/ODBC/Data Sources/MS Access 97 Database (not sharable).dsn;
MaxBufferSize=2048;
PageTimeout=5;UID=admin;";Initial Catalog=D:/CPP/NEWDB/IP
程序编译没错 运行时报错
代码:
procedure TForm1.BitBtn1Click(Sender: TObject);
var H:string;
begin
If Check(trim(Edit1.text)) then //Check Change自定义函数
begin
H:= Change(trim(Edit1.text));
ADOConnection1.Open;
ADOQuery1.Connection:= ADOConnection1;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from IP where IPStart like ''');
ADOQuery1.SQL.Add(H);
ADOQuery1.SQL.Add(''' and IPEnd like ''');
ADOQuery1.SQL.Add(H);
ADOQuery1.SQL.Add('''');
ADOQuery1.Open;
end
else showmessage('your input is not a illegle IP address!');
end;
ADOConnection字串:
Provider=MSDASQL.1;Persist Security Info=False;User ID=user;Mode=Read|Share Deny Write;
Extended Properties="DSN=MS Access 97 Database;DBQ=D:/CPP/NEWDB/IP.mdb;
DriverId=281;FIL=MS Access;
FILEDSN=C:/Program Files/Common Files/ODBC/Data Sources/MS Access 97 Database (not sharable).dsn;
MaxBufferSize=2048;
PageTimeout=5;UID=admin;";Initial Catalog=D:/CPP/NEWDB/IP
程序编译没错 运行时报错