//创建Access
AccessApplication.Connect;
AccessApplication.NewCurrentDatabase('c:\a.mdb');
AccessApplication.CurrentDb.NewPassword('""','clt');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AccessApplication.CloseCurrentDatabase;
AccessApplication.Disconnect;
用NewPassword但提示密码错误。
还有我还试过:
NewPassword('','clt');
NewPassword('''' + '' + '''','clt');
还是不行。
不知有谁能帮我。
AccessApplication.Connect;
AccessApplication.NewCurrentDatabase('c:\a.mdb');
AccessApplication.CurrentDb.NewPassword('""','clt');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AccessApplication.CloseCurrentDatabase;
AccessApplication.Disconnect;
用NewPassword但提示密码错误。
还有我还试过:
NewPassword('','clt');
NewPassword('''' + '' + '''','clt');
还是不行。
不知有谁能帮我。
//=============================================================================
// Procedure: CreateAccessFile
// Author : ysai
// Date : 2003-01-27
// Arguments: FileName:String;PassWord:string=''
// Result : boolean
//=============================================================================
function CreateAccessFile(FileName:String;PassWord:string=''):boolean;
//建立Access文件,如果文件存在则失败
var
STempFileName:string;
vCatalog:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vCatalog:=CreateOleObject('ADOX.Catalog');
vCatalog.Create(format(SConnectionString,[STempFileName,PassWord]));
result:=CopyFile(PChar(STempFileName),PChar(FileName),True);
DeleteFile(STempFileName);
except
result:=false;
end;
end;
还有NewPassword方法在dao35.hlp帮助文件中可以找到的
我根据上面的说明来做,就是提示密码错误。
不知有没有人通过这个方式解决?
Dim usrNew As User
Dim grpNew As Group
Dim grpMember As Group
Dim strPassword As String ' Get default workspace.
Set wrkDefault = DBEngine.Workspaces(0) With wrkDefault ' Create and append new user.
Set usrNew = .CreateUser("Pat Smith", _
"abc123DEF456", "Password1")
.Users.Append usrNew ' Create and append new group.
Set grpNew = .CreateGroup("Accounting", _
"UVW987xyz654")
.Groups.Append grpNew ' Make the new user a member of the new group.
Set grpMember = usrNew.CreateGroup("Accounting")
usrNew.Groups.Append grpMember ' Ask user for new password. If input is too long, ask
' again.
Do While True
strPassword = InputBox("Enter new password:")
Select Case Len(strPassword)
Case 1 To 14
usrNew.NewPassword "Password1", strPassword
MsgBox "Password changed!"
Exit Do
Case Is > 14
MsgBox "Password too long!"
Case 0
Exit Do
End Select
Loop ' Delete new User and Group objects because this
' is only a demonstration.
.Users.Delete "Pat Smith"
.Groups.Delete "Accounting" End WithEnd Sub
还有一个比较重要的问题是在“连接”标签下选中空白密码。还可以带密码压缩:dao.CompactDatabase(FileName,TempFile,'',0,';pwd=123456789'); 还有Diamond Access也能够给Access数据库加密码
var
TempStr:String;
begin
with Frm_NoteBook.ADOConnection1 do begin
Connected:=false;
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;' +
'Data Source='+ FileName +
';Mode=Share Deny Read|Share Deny Write;Extended Properties="";' +
'Jet OLEDB:System database="";' +
'Jet OLEDB:Registry Path="";' +
'Jet OLEDB:Database Password='+ OldPWD +';'+
'Jet OLEDB:Engine Type=5;' +
'Jet OLEDB:Database Locking Mode=1;' +
'Jet OLEDB:Global Partial Bulk Ops=2;' +
'Jet OLEDB:Global Bulk Transactions=1;' +
'Jet OLEDB:New Database Password="";' +
'Jet OLEDB:Create System Database=False;' +
'Jet OLEDB:Encrypt Database=False;' +
'Jet OLEDB:Don''t Copy Locale on Compact=False;' +
'Jet OLEDB:Compact Without Replica Repair=False;' +
'Jet OLEDB:SFP=False';
try
connected:=true;
if trim(OldPWD)='' then OldPWD:='null';
if trim(NewPWD)='' then NewPWD:='null';
TempStr:='ALTER Database Password '+ NewPWD + ' ' + OldPWD;
Execute(TempStr,cmdText,[eoExecuteNoRecords]);
result:=true;
except
msgbox('数据文件处理发生错误!','',16);
result:=false;
end;
end;
end;
那NewPassword到底有没有用?
照帮助上讲的可以1、加密码;2、修改密码;3、撤消密码
但是就是不能加密码。
还有,不知有没有人试过createdatabase,
我试呢一下,提示什么smia?(不知名字对不对)to anh(hananying)
我是要在delphi中,创建access是对access加上密码。不用用户操作的。