|
-
Mar 30th, 2006, 04:27 AM
#1
Thread Starter
Member
[RESOLVED] How to Unset Password?
How do I unset password of an MS access .mdb file using VB. net?
Soemone pls help...I've hunted high and low!!!
I'm using VB.net 2002 and access 2003
My connection string looks like this when i need to open my database
Dim cn As New ADODB.Connection()
Cn = New ADODB.Connection()
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_TTN_0001.mdb;Jet OLEDB: Database Password=xyyz")
-
Mar 31st, 2006, 03:09 AM
#2
Thread Starter
Member
Re: How to Unset Password?
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Assesssment_v2.exe
Additional information: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
------------------------------------------------------------------------
The above error is displayed by the code from below!! Where could I be going wrong...could someone help please!!!
the code in red color is the problem line
------------------------------------------------------------------------
Sub ResetDBPassword()
Dim DataConn As ADODB.Connection
'Dim Rec1 As ADODB.Recordset
Dim cn As ADODB.Connection
Dim sqlExecStr As String
Dim ResetQuestion As Integer
Dim ADOcon As New ADODB.Connection()
ADOcon.Open("Provider=Microsoft.Jet.OLEDB.4.0;Password=prax;User ID=Admin;Data Source=..\REPORTS_DB\TEST_TTN_0001.mdb;Persist Security Info=True")
On Error Resume Next
' Test to see if the database is open exclusively.
MsgBox("connection mode is " & cn.Mode)
If cn.Mode <> 12 Then
MsgBox("Your database is not opened exclusively", vbCritical)
Exit Sub
End If
ResetQuestion = MsgBox("You have selected to reset the database" & _
Chr(10) & Chr(13) & "to a blank password. Do you want to continue?", vbQuestion + vbYesNo, _
"Reset Database Password")
'Reset database password based on answer to message box.
If ResetQuestion = 6 Then
sqlExecStr = "ALTER DATABASE PASSWORD `` DBPassword"
cn.Execute(sqlExecStr)
MsgBox("Database Password has been reset.")
Else
MsgBox("Database password has not been reset")
Exit Sub
End If
End Sub
-
Apr 2nd, 2006, 10:28 PM
#3
Thread Starter
Member
Re: How to Unset Password?
Ahh I finally resolved the problem!!!
Sub ResetDBPassword()
Dim DataConn As ADODB.Connection
'Dim Rec1 As ADODB.Recordset
Dim cn As ADODB.Connection
Dim sqlExecStr As String
Dim ResetQuestion As Integer
Dim ADOcon As New ADODB.Connection()
ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_TTN_0001.mdb;Jet OLEDB atabase Password=password;User Id=Admin"
ADOcon.Mode = ConnectModeEnum.adModeShareExclusive
ADOcon.Open()
MsgBox("connection mode is " & Str(ADOcon.Mode))
'On Error Resume Next
' Test to see if the database is open exclusively.
If ADOcon.Mode <> 12 Then
MsgBox("Your database is not opened exclusively", vbCritical)
'Exit Sub
End If
ResetQuestion = MsgBox("You have selected to reset the database" & _
Chr(10) & Chr(13) & "to a blank password. Do you want to continue?", vbQuestion + vbYesNo, _
"Reset Database Password")
'Reset database password based on answer to message box.
If ResetQuestion = 6 Then
Try
sqlExecStr = "ALTER DATABASE PASSWORD `` password"
ADOcon.Execute(sqlExecStr)
MsgBox("Database Password has been reset.")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Else
MsgBox("Database password has not been reset")
Exit Sub
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|