Submitted on: 5/30/1999
By: Adam Abas
Level: Not Given
Compatibility:VB 5.0, VB 6.0
 
     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

code:
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

						
'**************************************
' 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


Blairs Hot Sauce | Shades | Free Blog Services | Illinois Bank Foreclosures | Business Insurance Auto TX