How you change the User password on the SQL server 6.5.
Windows API/Global Declarations:
'**************************************
'Windows API/Global Declarations for :Ho
' w You Change The Password on SQL Server
'**************************************
Option Explicit
'Note : you need to refrence MS SQLOLE t
' o your project first
Global SQLServerx As New SQLOLE.SQLServer
'**************************************
' Name: How You Change The Password on S
' QL Server
' Description:How you change the User pa
' ssword on the SQL server 6.5.
' By: Adam Abas
'
' Inputs:User Name,
OldPassword,
NewPassword.
'
' Returns:Password changed.
'
' Assumes:SQL server 6.5 and VB 5, 6
'
' Side Effects:I don't know if there is
' any effected side.In my computer works f
' ine.
'
'This code is copyrighted and has' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/xq/ASP/txtCode
' Id.1923/lngWId.1/qx/vb/scripts/ShowCode.
' htm'for details.'**************************************
Public Sub Changepassword()
Dim UserName As String * 20
UserName = "USER1" 'OR Get valid user name from the network using
'GetUserName From "advapi32.dll"
SQLServerx.DisConnect
SQLServerx.Connect ServerName:=SQLServer - Name, Login:="sa",
Password:=""
Dim MyLogins As SQLOLE.Login
On Error Goto Badpassword
'Note: old password must be valid passwo
' d for same above user on the SQL server
For Each MyLogins In SQLServerx.Logins
If MyLogins.Name = Trim(UserName) Then
MyLogins.SetPassword oldpassword:="123456",
NewPassword:="222222"
Else
End If
Next
Exit Sub
Badpassword:
MsgBox "Sorry,,Incorrect old password, try later or call SA.. !"
End Sub