codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Change password in database through VB! please read!!  greenelephant at 19:34 on Sunday, February 15, 2004
 

Hi there im new to visual basic and need ur help please!!!

Im trying to create a change password dialog with 3 textboxes. One for username, old password and new password. I've sucessfully connected to the MS Access 2000 database with MS jet 4.0 but dont the vb code to complete the dialog box. Inside the database each record represents one person. And theres two columns, 1 for username and password. They are called StaffUserName and StaffPassword. OK heres the scenario

1. User enters their data into all 3 boxes
2. vb using text in text box for username searches database for identical username in database. If not msgbox saying Username is incorrect
3. database fixes onto that specific record.
4. vb code saying if both username and password in textboxes matches database fields. StaffPassword changes to value in NewPassword textbox
5. msgbox saying change complete

If n e 1 can help me i would apreciate it very much. I need this for a college project! Thanx

  Re: Change password in database through VB! please read!!  jennesys at 03:08 on Tuesday, February 24, 2004
 

You are going to have a problem with this unless you ensure that the user name is unique because later you are going to have to rely upon that value for the update to the record. Ideally you will have a unique key that you should retrieve when you validate the UID and password. Also, you should require two text fields for the new password and ensure that they are equal. Here is the code to find the dB record:
'make the db connection
'retrieve the information on the user
'validate the password
'query db by user id
'this is where the connection is established

Dim txtConn As String
txtConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & gblDBPath & gbldBName & ";Persist Security Info=False"
Dim objConn As ADODB.Connection
Set objConn = New ADODB.Connection
objConn.ConnectionString = txtConn
objConn.Open

'this is where the command is established and executed through the connection
Dim objComm As ADODB.Command
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandType = adCmdText

Dim rs As ADODB.Recordset



txtSQL = "SELECT user.name, user.password " & _
"FROM [user] " & _
"WHERE (user.userID='" & txtUserName & "');"


objComm.CommandText = txtSQL

Set rs = New ADODB.Recordset

Set rs.Source = objComm

rs.Open

If (rs.EOF And rs.BOF) Then
'user id not found
Exit Sub
Else
'now, set up the command text for the update
'this is off the top of my head so, it may have an error or two
txtSQL = "UPDATE [user] SET "
txtSQL = txtSQL & " user.password= '" & txtNewpassword & "', "
txtSQL = txtSQL + " WHERE (((user.userID)= '" & txtUserName & "'));"

objComm.CommandText = txtSQL

objComm.Execute
end if









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo
•  Cookies and Threads C++
•  right justify a background in a table?
•  Help with Loop (C++/MFC)
•  Help with Loop (C++/MFC)


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007