can anyone help me with my problem?
i'm trying to set a password in my database using vb.net.
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
db.Close()
objconn.Close()
conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & mdi_main.dlg_open.FileName & ";"
conDatabase.Open()
strsql = "ALTER DATABASE PASSWORD ="
'sql.ActiveConnection = conDatabase
'sql.CommandText = strsql
conDatabase.Execute(strsql)
'sql.Execute(sql)
MsgBox("The new password was successfully set.", vbInformation)
Else
MsgBox("Mali ung type mo")
End If
'conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & mdi_main.dlg_open.FileName & ";"
'conDatabase.Open()
'strsql = " ALTER DATABASE PASSWORD " & strdbsetpassword
'With sql
'.ActiveConnection = conDatabase
'.CommandText = strsql
'.Execute(strsql)
'End With
'conDatabase.Close()
'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 & ";")
'conDatabase.Open()
'strsql = "ALTER DATABASE PASSWORD" & strdbsetpassword & "NULL"
'sql.ActiveConnection = conDatabase
'sql.CommandText = strsql
'sql.Execute(strsql)
'conDatabase.Execute(strsql)
'conDatabase.Close()
'MsgBox("Setting of Password done!")
Else
'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..
thanks!