Using C#:
using System.Data.SqlClient; ... SqlConnection oSQLConn = new SqlConnection(); oSQLConn.ConnectionString = "Data Source=(local);" + "Initial Catalog=mySQLServerDBName;" + "Integrated Security=yes"; oSQLConn.Open();
If connection to a remote server (via IP address):
oSQLConn.ConnectionString = "Network Library=DBMSSOCN;" & _ "Data Source=xxx.xxx.xxx.xxx,1433;" & _ "Initial Catalog=mySQLServerDBName;" & _ "User ID=myUsername;" & _ "Password=myPassword" Where: - "Network Library=DBMSSOCN" tells SqlConnection to use TCP/IP Q238949
- xxx.xxx.xxx.xxx is an IP address.
- 1433 is the default port number for SQL Server. Q269882 and Q287932
- You can also add "Encrypt=yes" for encryption
Connection String Examples
Data source | Example | Description |
---|---|---|
SQL Server database on the local server | data source="(local)";initial catalog=AdventureWorks | Set data source type to SQL Server. |
SQL Server instance database | Data Source=localhost\MSSQL10_50.InstanceName; Initial Catalog= AdventureWorks | Set data source type to SQL Server. |
SQL Server Express database | Data Source=localhost\MSSQL10_50.SQLEXPRESS; Initial Catalog= AdventureWorks | Set data source type to SQL Server. |
Analysis Services database on the local server | data source=localhost;initial catalog=Adventure Works DW | Set data source type to SQL Server Analysis Services. |
SharePoint List | data source=http://MySharePointWeb/MySharePointSite/ | Set data source type to SharePoint List. |
SQL Server 2000 Analysis Services server | provider=MSOLAP.2;data source= | Set the data source type to OLE DB Provider for OLAP Services 8.0. You can achieve a faster connection to SQL Server 2000 Analysis Services data sources if you set the ConnectTo property to 8.0. To set this property, use the Connection Properties dialog box, Advanced Properties tab. |
Report Models | Not applicable. | You do not need a connection string for a report model. In Report Builder, browse to the report server and select the .smdl file that is the report model. |
Oracle server | data source=myserver | Set the data source type to Oracle. The Oracle client tools must be installed on the Report Builder computer and on the report server. |
SAP NetWeaver BI data source | DataSource=http://mySAPNetWeaverBIServer:8000/sap/bw/xml/soap/xmla | Set the data source type to SAP NetWeaver BI. |
Hyperion Essbase data source | Data Source=http://localhost:13080/aps/XMLA; Initial Catalog=Sample | Set the data source type to Hyperion Essbase. |
Teradata data source | data source= | Set the data source type to Teradata. The connection string is an Internet Protocol (IP) address in the form of four fields, where each field can be from one to three digits. |
Teradata data source | Database= | Set the data source type to Teradata, similar to the previous example. Only use the default database that is specified in the Database tag, and do not automatically discover data relationships. |
XML data source, Web service | data source=http://adventure-works.com/results.aspx | Set the data source type to XML. The connection string is a URL for a web service that supports Web Services Definition Language (WSDL). |
XML data source, XML document | http://localhost/XML/Customers.xml | Set the data source type to XML. The connection string is a URL to the XML document. |
XML data source, embedded XML document | Empty | Set the data source type to XML. The XML data is embedded in the report definition. |
No comments:
Post a Comment