ado怎么连接加密的access数据库呀,给个代码啊 ( 积分: 50 )

  • 主题发起人 主题发起人 lunyx_allen
  • 开始时间 开始时间
L

lunyx_allen

Unregistered / Unconfirmed
GUEST, unregistred user!
我的数据库文件是&nbsp;a.mdb&nbsp;,密码是admin;&nbsp;&nbsp;&nbsp;我用adoconnnection连接的时候动态设置它的代码如下:<br>&nbsp;&nbsp;ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password=admin;Data&nbsp;Source=a.mdb;Persist&nbsp;Security&nbsp;Info=True';&nbsp;<br>可是连接不成功,提示什么“工作组信息文件丢失,或者被用户以独占方式打开”,可我没设什么工作组啊,就一个密码而已。请仙人指点啊
 
Provider=Microsoft.Jet.OLEDB.4.0;Password=&quot;&quot;;Data&nbsp;Source=a.mdb;Persist&nbsp;Security&nbsp;Info=True;Jet&nbsp;OLEDB:Database&nbsp;Password=123
 
不对不给分<br>adocon1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Jet&nbsp;OLEDB:Database&nbsp;Password=xzxq;Data&nbsp;Source='+extractfiledir(application.ExeName)+'/jfsj.mdb;Persist&nbsp;Security&nbsp;Info=False';
 
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password=''admin'';Data&nbsp;Source=''a.mdb'';Persist&nbsp;Security&nbsp;Info=True';
 
DM.Conn.Close;<br>&nbsp;&nbsp;&nbsp;&nbsp;DM.Conn.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data&nbsp;Source='<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ExtractFilePath(Application.ExeName)+'/uses/NewPQMs.mdb;Jet&nbsp;OLEDB:database&nbsp;password=123;Persist&nbsp;Security&nbsp;Info=False';<br>&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM.Conn.Open;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;showmessage('Error');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;showmessage('Ok');
 
//我程序上的源码<br>var<br>&nbsp;&nbsp;ODBCreg:&nbsp;TRegistry;<br>&nbsp;&nbsp;DataFileName&nbsp;,&nbsp;&nbsp;&nbsp;sfilepath:string;<br>begin<br>&nbsp;&nbsp;sfilepath&nbsp;:=&nbsp;GetCurrentDir&nbsp;+&nbsp;'/data/';<br>&nbsp;&nbsp;DataFileName&nbsp;:=&nbsp;'address';<br>&nbsp;&nbsp;ODBCreg&nbsp;:=&nbsp;TRegistry.create;<br>&nbsp;&nbsp;ODBCreg.RootKey&nbsp;:=&nbsp;HKEY_CURRENT_USER;<br>&nbsp;&nbsp;ODBCreg.OpenKey('SOFTWARE/ODBC/ODBC.INI/address',&nbsp;true);<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteString('Driver',&nbsp;'C:/WINDOWS/System32/odbcjt32.dll');<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteString('DBQ',&nbsp;sfilepath&nbsp;+&nbsp;'Address.dat');<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteString('FIL',&nbsp;'MS&nbsp;Access;');<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteString('UID',&nbsp;'');<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteInteger('SafeTransactions',&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.WriteInteger('DriverId',&nbsp;25);<br>&nbsp;&nbsp;finally&nbsp;//&nbsp;wrap&nbsp;up<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.CloseKey;<br>&nbsp;&nbsp;&nbsp;&nbsp;ODBCreg.Free;<br>&nbsp;&nbsp;end;&nbsp;//&nbsp;try/finally<br>&nbsp;&nbsp;ADOConnection1.ConnectionString&nbsp;:=<br>&nbsp;&nbsp;//&nbsp;&nbsp;'Provider=Microsoft.Jet.OLEDB.4.0;Data&nbsp;Source='&nbsp;+&nbsp;Sfilepath&nbsp;+&nbsp;DataFileName&nbsp;+<br>&nbsp;&nbsp;&nbsp;//&nbsp;'.dat;Persist&nbsp;Security&nbsp;Info=False';<br>&nbsp;&nbsp;'Provider=MSDASQL.1;Password=abc;Persist&nbsp;Security&nbsp;Info=True;Data&nbsp;Source='&nbsp;+&nbsp;DataFileName;<br>&nbsp;&nbsp;if&nbsp;ADOConnection1.Connected&nbsp;=&nbsp;false&nbsp;then&nbsp;ADOConnection1.Connected&nbsp;:=&nbsp;true;<br>&nbsp;&nbsp;ComboBoxField.Items.Clear;<br>&nbsp;&nbsp;Query1.Close;<br>&nbsp;&nbsp;Query1.SQL.Clear;<br>&nbsp;&nbsp;Query1.SQL.Add('select&nbsp;*&nbsp;from&nbsp;address');<br>&nbsp;&nbsp;query1.Open;<br>&nbsp;&nbsp;query1.GetFieldNames(ComboBoxField.Items);<br>&nbsp;&nbsp;ComboBoxField.Items.Delete(0);<br>&nbsp;&nbsp;ComboBoxField.Items.Delete(13);<br>&nbsp;&nbsp;Query1.Close;<br>&nbsp;&nbsp;Query1.SQL.Clear;<br>&nbsp;&nbsp;Query1.SQL.Add('select&nbsp;ID,姓名,性别,生日,电子邮件,籍贯,电话,手机,传真,单位,地址,职务,邮编,备注,'&nbsp;+<br>&nbsp;&nbsp;&nbsp;&nbsp;'录入时间&nbsp;from&nbsp;'&nbsp;+&nbsp;DataFileName&nbsp;+&nbsp;'&nbsp;order&nbsp;by&nbsp;姓名');<br>&nbsp;&nbsp;//session.AddPassword('enter');<br>&nbsp;&nbsp;Query1.open;<br>end;
 
后退
顶部