'ALTER DATABASE PASSWORD' does not work for me

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
 
H

Hans Up

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top