Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Function UpdatePassword() As Boolean
' ******************************************************************************
'
' Function to execute the sp_password stored procedure on the SQL server
' used to allow users to change their own password
' Written by J Barnett (MIS Officer), 12-15 May 2006.
'
*******************************************************************************
Dim lngCount As Long
Dim cmd As ADODB.Command
On Error GoTo err_DBConnect
' Build SQL Server TCP/IP connection string based on the username and existing password on the form.
' Components are as follows:
' Provider=SQLOLEDB - Driver
' Data Source = IP address, port of server
' Network Library = Database connection library to use (this means "use TCP/IP")
' Initial catalog = Database to switch to
' User ID and password are the details of the SQL accounts to connect as
strDBConnect = "PROVIDER='SQLOLEDB';Data Source=<server dns name or ip address>;Network Library=DBMSSOCN;Initial Catalog=<dbname>;User id = " & Me.txtUsername & "; Password = " & Me.txtCurrentPass & ";"
If Me.txtUsername = "sa" Then
' Don't let anyone change the SQL Server SA account via this application, just let it fail gracefully...
UpdatePassword = False
Exit Function
End If
' Connect to the server
' Set up a command object to execute the stored procedure
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = gcnn
.CommandType = adCmdStoredProc ' Evaluate CommandText as a stored procedure (rather than plain text or autodetect, runs faster).
.CommandText = "sp_password" ' Name of SP to execute
.CommandTimeout = 30 ' Timeout to fail after (seconds)
.Parameters.Append .CreateParameter("old", adVarChar, adParamInput, 128, Me.txtCurrentPass) ' old parameter = current password
.Parameters.Append .CreateParameter("new", adVarChar, adParamInput, 128, Me.txtNewpass) ' new parameter = new password
.Execute lngCount ' execute SP and return the number of rows affected to lngCount variable
End With
Exit_DBConnect:
If lngCount = 0 Then
UpdatePassword = False
Else
UpdatePassword = True
End If
Exit Function
err_DBConnect:
Select Case Err.Number
Case -2147217843 ' Incorrect username/password
UpdatePassword = False
Resume Exit_DBConnect
Case Else
If Err.Number <> 0 Then Debug.Print Err.Number & " " & Err.Description
Resume Next
End Select
End Function