'ALTER DATABASE PASSWORD' does not work for me

  • Thread starter Thread starter mickey
  • Start date Start date
M

mickey

Hi All
I hope this is the right group for this problem.
I'm trying to change an access database password using vb.net

I successfully open it with the following connect string:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\abc.mdb;Jet OLEDB:Database
Password=fredflintstone;Mode= 12
where I beleive that 'Mode=12' is exclusive access

Then I then try to execute this query
cm.CommandText = "ALTER DATABASE PASSWORD " & newPassword & " "
& oldPassWord
Try

rs = cm.Execute
Catch ex As Exception
MsgBox(ex.Message)
End Try
This is the ex.Message
The connection cannot be used to perform this operation. It is either closed
or invalid in this context.

Thanks
Mickey
 
mickey said:
I successfully open it with the following connect string:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\abc.mdb;Jet
OLEDB:Database Password=fredflintstone;Mode= 12
where I beleive that 'Mode=12' is exclusive access

Then I then try to execute this query
cm.CommandText = "ALTER DATABASE PASSWORD " & newPassword & "
" & oldPassWord
Try

rs = cm.Execute
Catch ex As Exception
MsgBox(ex.Message)
End Try
This is the ex.Message
The connection cannot be used to perform this operation. It is either
closed or invalid in this context.

So "rs" is a Recordset object and "cm" is a Command object?

It looks to me like you're trying to execute a SQL statement which
returns no records and feed the results to a Recorset. I don't know how
that can work.

Assuming you have a Connection object, "cn", you might try:

cn.Execute "ALTER DATABASE PASSWORD " & newPassword & " " & oldPassWord

Good luck,
Hans
 
Back
Top