The ADO.NET provider for ServiceNow provides a wide range of features that enable connectivity to ServiceNow from .Net applications. The documentation will help you understand the C1.AdoNet.ServiceNow namespace, which includes all the available classes that can be used to connect and retrieve data from an ServiceNow service.
DataConnectors are mostly used in combination with other ComponentOne components, such as DataEngine and FlexPivot. The procedure below describes how to use the DataConnector in a console application within Visual Studio.
The ADO.NET provider for ServiceNow can be used in any application. In this guide, a console application is created:
Follow the steps provided below to learn and implement data retrieval using ADO.NET provider for ServiceNow.
C# |
コードのコピー
|
---|---|
//接続文字列を定義します。 string connectionString = @"Username= yourusername; Password= yourpassword; Oauth Client Id= yourid; Oauth Client Secret= yoursecretcode; Oauth Token Endpoint= http://****/****/****; Url= http://****/****/****"; |
C# |
コードのコピー
|
---|---|
using (C1ServiceNowConnection conn = new C1ServiceNowConnection(connectionString)) { //DataTable を設定します。 C1ServiceNowDataAdapter adapter = new C1ServiceNowDataAdapter(conn, "Select caller_id, category, description, close_code from incident"); DataTable dataTable = new DataTable(); var i = adapter.Fill(dataTable); if (i != -1) { //取得したデータを表示します。 foreach (DataRow row in dataTable.Rows) { Console.WriteLine("CallerId:{0}", row["caller_id"]); Console.WriteLine("Category:{0}", row["category"]); Console.WriteLine("Description:{0}", row["description"]); Console.WriteLine("CloseCode:{0}", row["close_code"]); Console.WriteLine("\n"); } Console.WriteLine("Read operation successful !!! \n \n"); } } |
The following output is generated on the console application on executing the above steps.