| Author: saidev mohapatra 26 Sep 2006 | Member Level: Bronze | Rating: Points: 2 |
OLE DB Provider for SQL Server
For Standard security strConnect = _T("Provider=sqloledb;Data Source=MyServerName;" "Initial Catalog=MyDatabaseName;" "User Id=MyUsername;Password=MyPassword;");
For Trusted Connection security (Microsoft Windows NT integrated security) strConnect = _T("Provider=sqloledb;Data Source=MyServerName;" "Initial Catalog=MyDatabaseName;" "Integrated Security=SSPI;");
If you want to connect to a "Named Instance" (SQL Server 2000), you must to specify Data Source=Servere Name\Instance Name like in the following example: strConnect = _T("Provider=sqloledb;Data Source=MyServerName\MyInstanceName;" "Initial Catalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword;");
If you want to connect with a SQL Server running on the same computer, you must specify the keyword (local) in the Data Source like in the following example: strConnect = _T("Provider=sqloledb;Data Source=(local);" "Initial Catalog=myDatabaseName;" "User ID=myUsername;Password=myPassword;");
To connect to SQL Server running on a remote computer (via an IP address):
strConnect = _T("Provider=sqloledb;Network Library=DBMSSOCN;" "Data Source=130.120.110.001,1433;" "Initial Catalog=MyDatabaseName;User ID=MyUsername;" "Password=MyPassword;");
Sai
|