can anyone help me with my problem?
i'm trying to set a password in my database using
here's my codes..

Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click
Dim chkpass As Integer

Dim strsql As String
Dim conDatabase As ADODB.Connection
conDatabase = New ADODB.Connection
'Dim sql As ADODB.Command
'sql = New ADODB.Command

'Dim hi As New ADODB.Connection
'Dim dbConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & mdi_main.dlg_open.FileName & ";"
'hi.ConnectionString = dbConnection

If txt_password.Text = "" Or txt_confirmpassword.Text = "" Then 'txt_confirmpassword.Text = Nullable Or txt_password.Text = Nullable Then
MsgBox("Enter both and new and confirm password")
Exit Sub
End If
strdbsetpassword = txt_confirmpassword.Text
chkpass = StrComp(txt_password.Text, txt_confirmpassword.Text, vbBinaryCompare)

If chkpass = 0 Then
conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & mdi_main.dlg_open.FileName & ";"
'sql.ActiveConnection = conDatabase
'sql.CommandText = strsql
MsgBox("The new password was successfully set.", vbInformation)
MsgBox("Mali ung type mo")
End If

'conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & mdi_main.dlg_open.FileName & ";"
'strsql = " ALTER DATABASE PASSWORD " & strdbsetpassword
'With sql
'.ActiveConnection = conDatabase
'.CommandText = strsql
'End With
'Dim SQL As String
'Dim intCheckPwd As Integer

'conDatabase("Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & mdi_main.dlg_open.FileName & "")

If scan_openfilenameformdb <> 0 Then
'strconnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & mdi_main.dlg_open.FileName

'conDatabase.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & mdi_main.dlg_open.FileName & ";Persist Security Info=True;" & "Jet OLEDB:Database Password=", strdbsetpassword, strdbsetpassword & ";")

'strsql = "ALTER DATABASE PASSWORD" & strdbsetpassword & "NULL"
'sql.ActiveConnection = conDatabase
'sql.CommandText = strsql
'MsgBox("Setting of Password done!")

'If scan_openfilenameforaccdb <> 0 Then
'strconnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & mdi_main.dlg_open.FileName & ";Persist Security Info=True;" & "Jet OLEDB:Database Password= chkpass " & ";"
'MsgBox("Setting of Password done!")
'End If
End If

End Sub

Is there something wrong with my codes?
The error was: INVALID PASSWORD..
pLZ... help me..

This link seems to indicate you need both the old password and the new password

So your code should be changed where you assign the value to strSQL:
strSQL="ALTER DATABASE PASSWORD [" & newPassword & "] [" & oldPassword & "]"

But your users will need to additionally supply the old password

eg dialog box that gets three passwords - old, new & confirm new

the old password gives your user the right to change the password, then your confirmation logic proves that their typing is accurate ;)

This article has been dead for over six months. Start a new discussion instead.