# Creating Connection

## Content



To create a connection to a ServiceNow data source, the ADO.NET Provider can be used through the [C1ServiceNowConnection](/componentone/api/services/online-dataconnector/dotnet-standard-api/C1.AdoNet.ServiceNow/C1.AdoNet.ServiceNow.C1ServiceNowConnection.html) class. This expects to be passed a connection string as an argument, which can be either:

*   Generated using the [C1ServiceNowConnectionStringBuilder](/componentone/api/services/online-dataconnector/dotnet-standard-api/C1.AdoNet.ServiceNow/C1.AdoNet.ServiceNow.C1ServiceNowConnectionStringBuilder.html) class by specifying individual statements.
*   Constructed manually by writing the connection string directly.

### Connection string generation

The following code shows how **C1ServiceNowConnectionStringBuilder** class can be used to configure the connection string for ServiceNow and consumed by the **C1ServiceNowConnection** class to create a connection to the server. Here, you can query the data.

```csharp
//Create connection string using C1ServiceNowConnectionStringBuilder
connBuilder.Username = @"*******";
connBuilder.Password = @"*******";
connBuilder.OAuthClientId = @"*******";
connBuilder.OAuthClientSecret = @"*******";
connBuilder.OAuthTokenEndpoint = @"http://****/****/****";
connBuilder.Url = @"http://****/****/****";
//Create and establish a connection
C1ServiceNowConnection conn = new C1ServiceNowConnection(connBuilder)
```

### Connection string literal

Alternatively, the connection string can be written directly as a string literal like in the code example below. A similar approach can be implemented in other DataConnectors for ADO.NET provider.

```csharp
//Define connection string
string connectionString = @"Username= *******; Password= *******; Oauth Client Id= *******; 
Oauth Client Secret= *******; Oauth Token Endpoint= http://****/****/****; Url= http://****/****/****";
//Create and establish a connection
C1ServiceNowConnection conn = new C1ServiceNowConnection(connectionString);
```