Readme_Changing a SQL Server Authentication User Password (OLE DB)
This sample works only with SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2008.
This sample shows how to use OLE DB to change the password of a user account under SQL Server Authentication.
SQL Server samples and sample databases must be downloaded and installed before you can view or work with them. For more information, see Considerations for Installing SQL Server Samples and Sample Databases
This sample uses Visual C++.
Before running this sample, make sure that the following software is installed:
- SQL Server 2008 or SQL Server Express, including Database Engine. You can download SQL Server Express from the Microsoft Download Center.
- The SQL Server Database Engine samples that are available at at the Microsoft SQL Server Developer Center. This sample will use the AdventureWorks database.
- The .NET Framework SDK 2.0 (or later) or Microsoft Visual Studio 2005 (or later). You can obtain the .NET Framework SDK free of charge. For more information, see Installing the .NET Framework Documentation.
- A SQL Server Authentication user account for which you know the password. To allow logins under SQL Server Authentication, open SQL Server Management Studio, right click on the Server node in Object Explorer, and select Properties. Select Security and enable SQL Server and Windows Authentication mode. To add a user account under SQL Server Authentication, right click the Security node in Object Explorer and select Add.
- The server on which you will run this sample must have at least one login enabled for SQL Server Authentication. The server must also be enabled to allow SQL Server Authentication logins.
Building the Sample
- This sample connects to your computer's default SQL Server instance. Note that on some Windows operating systems, you will have to change (localhost) or (local) to the name of your SQL Server instance. To connect to a named instance, change the connection string from L"(local)" to L"(local)\\name" , where name is the named instance. By default, SQL Server Express installs to a named instance.
- Make sure that your INCLUDE environment variable includes the directory that contains sqlncli.h.
- Before building, update ChangeSQLServerPassword.cpp to specify the user ID, old password, and new password.
- If you are using Visual Studio, load the ChangeSQLServerPassword.sln file and build it.
- If you are using MSBuild.exe, invoke MSBuild.exe at a command prompt, passing in the ChangeSQLServerPassword.sln file as follows: * MSBuild ChangeSQLServerPassword.sln *
Running the Sample
- From Visual Studio, invoke Start Without Debugging (CTRL+F5).
- If you built with MSBuild.exe, invoke ChangeSQLServerPassword.exe.
Data Access Samples
Help and Information
- Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.