Home > PHP, SQL Server > Microsoft SQL Server ODBC Driver Configuration

Microsoft SQL Server ODBC Driver Configuration

Steps:
1. Click Control Panel -> All Control Panel Items -> Administrative Tools -> Data Sources (ODBC)

Click Data Sources (ODBC)

Click Data Sources (ODBC)

2. Opens the ODBC Data Source Administrator Pop-up.

3. Select the User DSN -> Click the ADD button to add new DSN

Click the ADD Button

Click the ADD Button

4. Opens a Create New Data Source Pop-up. Select SQL Server and click Finish.

5. Now opens another Pop-up for Database Connection
6. Enter Name, Description for the connection.
7. In SERVER: field provide the server name/ IP and Instance Name

Ex:   10.10.10.20/SQL2005

SQLExpress/SQL2005

Click Next

Click Next

8. Click Next will ask for DB Mapping.

Check the Change the default database to.

In the Change the default database to box, use the pull down list to select the SQL database name that you created using SQL SERVER 2005 MANAGEMENT STUDIO.

Select the required DB.

Select the reruired DB

Select the reruired DB

9. Check Use ANSI quoted identifiers.

Check Use ANSI nulls, paddings and warnings.

   Click Next.

10.  Select Use regional settings…… and click Finish.

11. Click the Test Data Source and Test it.

12. We will get the following successful message dialog box.

13.   Select OK 3 times (one for each dialog box) to exit ODBC configuration.

If it did not Test Successfully.

Try these steps:

–  If the SQL Server is a remote node, verify that TCP port 1433 is open on the SQL Server Node (i.e. check any firewalls or Windows Firewall).

–  Verify the SA Login Password or whatever Login ID you used to configure this DSN.

– Verify the Database name.

– Verify that SQL Server is running.

13. Now we will get the connection Name in the User DSN.

We can see the created DSN name here

We can see the created DSN name here

10. Thats It. Connection has been successfully created for SQL Server through ODBC

We will see how we can access through PHP,

<?php/*

PHP MSSQL Example

Replace data_source_name with the name of your data source.

Replace database_username and database_password

with the SQL Server database username and password.

*/

$data_source=”Driver={SQL Server};Server=10.10.10.20\SQL2005;Database=Name of the DB;”;

$user=’sa’; // Username of the SQL server

$password=’Xxxxxx456′; // Password of the SQL server

// Connect to the data source and get a handle for that connection.

$conn=odbc_connect($data_source,$user,$password);

if($conn)

echo ‘success’;

else

echo ‘failed’;

?>

Advertisements
Categories: PHP, SQL Server
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: