ADO.NET Provider for SAP HANA XSA

Build 23.0.8839

Querying with the DataAdapter

The CData ADO.NET Provider for SAP HANA XSA implements two ADO.NET interfaces you can use to retrieve data from SAP HANA XSA: SAPHanaXSADataAdapter and SAPHanaXSADataReader objects. Whereas SAPHanaXSADataAdapter objects retrieve a single result set of all the data that matches a query, SAPHanaXSADataReader objects fetch data in subset increments as needed.

Using the SAPHanaXSADataAdapter

Use the adapter's Fill method to retrieve data from the data source. An empty DataTable instance is passed as an argument to the Fill method. When the method returns, the DataTable instance is populated with the queried data. Note that the SAPHanaXSADataAdapter is slower than the SAPHanaXSADataReader because the Fill method needs to retrieve all data from the data source before returning.

The following example selects the Id and Column1 columns of the SampleTable table:

C#

string connectionString = "User=MyUser;Password=MyPassword;URL=https://hxehost:51027/euro.xsodata;";

using (SAPHanaXSAConnection connection = new SAPHanaXSAConnection(connectionString)) {
  SAPHanaXSADataAdapter dataAdapter = new SAPHanaXSADataAdapter(
  "SELECT Id, Column1 FROM SampleTable", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of SampleTable.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["Id"], row["Column1"]);
  }
}

VB.NET

Dim connectionString As String = "User=MyUser;Password=MyPassword;URL=https://hxehost:51027/euro.xsodata;"

Using connection As New SAPHanaXSAConnection(connectionString)
  Dim dataAdapter As New SAPHanaXSADataAdapter("SELECT Id, Column1 FROM SampleTable", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of SampleTable.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("Id"), row("Column1"))
  Next
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839