0

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!

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by SadOldMisterHam
0

This link seems to indicate you need both the old password and the new password
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/4a2e342e-d7e4-4aaf-a1e3-f57248d9ebde


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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.