delphi ADO组件动态连接access数据库


本文整理自网络,侵删。

 1.

try
adoconnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source='+ExtractFilePath(Paramstr(0))+'picture.mdb;Persist Security Info=True';
adoconnection1.connected:=true;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select* from test');
adoquery1.Open;
button1.Enabled:=false;
showmessage('连接数据库成功');
except
showmessage('数据库连接错误');
end
这只是个例子

2.

很简单,调用一个API即可
例:
with ADOQuery1 do
begin
ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + ExtractFilePath (Application.ExeName) + 'db1.mdb;Pe' +
'rsist Security Info=False';
end;

///////////////////////////////////////////////////////////////
with AdoConnection1 do
begin
connectionstring :='Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='+你的数据库名成+'; Persist Security Info=False;
Jet OLEDB:Database Password= ********';
actice := true ;
{
try
except
end;...............
}
end;

//////////////////////////////////////////////////////////////////////

var
ConnStr,DBPath:String;
try
DBPath:='你的数据库数径全的';
ConnStr:='Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='+数据库名称+'; Persist Security Info=False;
Jet OLEDB:Database Password=密码';
ADOConnection1.ConnectionString:=ConnStr;
ADOConnection1.Open;
Except
ShowMessage('数据库打开失败');
end;

相关阅读 >>

Delphi rest客户端程序

Delphi textfile utf8编码读写

Delphi datetimepicker控件日期格式

Delphi 为数字补充前缀0

Delphi html转义

Delphi 如何从html格式的字符串中提取纯文本?

Delphi 提高unigui开发效率的两个方法

Delphi 如何将颜色值转换为html格式?

orangeui作者开源作品

Delphi 如何将颜色值转换为灰度颜色值?

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...