Professional Documents
Culture Documents
Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner
About
About
Ask a Question Write a Blog Post Login
Former Member
SAP HANA
integration option for Microsoft Office SharePoint software | Business Intelligence | Database | hana | integration option for
microsoft sharepoint software | net | sap
With the advent of HANA SPS 08 circa Q2 2014, SAP finally released the
HANA data provider for Microsoft ADO.NET. Admittedly, this is not trousers
stirring news this but I am pleased to know that there is now an effective
way to allow the .NET framework to efficiently communicate with SAP
HANA. In the past, you could still do that but it was through the use of the
ODBC driver – there is nothing wrong with it if all you wanted to do was to
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 1/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
connect to SAP HANA and perform some simple SQL statements but we all
know SAP HANA if more than just an in memory database.
This article will to tease out some of the key concepts and features
introduced by SPS 08 on the client interfaces for ADO.NET. Data access
and manipulation will be the theme here today using C# and SAP’s new
.NET API – Sap.Data.Hana. If you are wondering what ADO.NET is, it is
Microsoft data access technology for the .NET framework using
programming languages such as C# or VB.NET.
I beg the question that you ask why is it important for SAP to release this
new API when ODBC is sufficient? Given that the standard ODBC
connection to SAP HANA is still a valid method to bridge the connection to
the database or any database for that matter, we need to understand the
core use of an ODBC driver itself. Microsoft’s primary goal when they
released the initial ODBC driver was to provide a vendor neutral way of
accessing stored data in any
machine. As you might have already guessed, the whole host of ODBC
driver that Microsoft currently supports spans vast and wide from databases
such as Oracle, Informix, Teradata and all the way to SAP HANA, just to
name a few. The result of building an ODBC driver to be as generic as
possible can come at a cost. Cost in terms of lost of performance,
unleveraged hidden features, missing core functionalities and best practices
surrounding a given database.
Getting Started
To start using the new ADO.NET API delivered in SPS 08, you will need to
have the latest SAP HANA Client Developer Edition version 1.00.80
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 2/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
Under the .NET solution explorer, expend the Reference dropdown and
ensure that Sap.Data.Hana.v4.5 has been included to your .NET solution
and if not you can add a new reference under the Extensions path. Once
you have that, standard C #codes ensue for namespace: using
Sap.Data.Hana;
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 3/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
Selecting records
conn.Open();
dgViewTweet.DataSource = reader;
reader.Close();
conn.Close();
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 4/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
Inserting records into the database is as easy as querying for it but not
without additional effort to format and prepare the data. The example
provided here stores the information from 5 text fields using standard SQL
inserts statements executed by C#.
Upon loading the application, it connects to SAP HANA, loads 150 rows of
customer records from the database and the intention here is to create a
new piece of information and write it back to the table.
When the Save New button is clicked, the .NET framework runs through
this piece of simple code to perform two sets of activities. Firstly, it will
perform a SQL insert statement to store all the values captured from the
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 5/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
conn.Open();
sCust = txtCustomer.Text;
sLifespend = txtLifespend.Text;
sNewspend = txtNewspend.Text;
sIncome = txtIncome.Text;
sLoyalty = txtLoyalty.Text;
//Customer
parm.HanaDbType = HanaDbType.NVarChar;
insertCmd.Parameters.Add(parm);
//Life Spend
parm.HanaDbType = HanaDbType.Double;
insertCmd.Parameters.Add(parm);
//New Spend
parm.HanaDbType = HanaDbType.Double;
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 6/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
insertCmd.Parameters.Add(parm);
//Income
parm.HanaDbType = HanaDbType.Double;
insertCmd.Parameters.Add(parm);
//Loyalty
parm.HanaDbType = HanaDbType.Double;
insertCmd.Parameters.Add(parm);
//Customers
insertCmd.Parameters[1].Value = sCust;
//Life Spend
insertCmd.Parameters[2].Value = sLifespend;
//New Spend
insertCmd.Parameters[3].Value = sNewspend;
//Income
insertCmd.Parameters[4].Value = sIncome;
//Loyalty
insertCmd.Parameters[5].Value = sLoyalty;
insertCmd.ExecuteNonQuery();
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 7/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
dgViewTweet.DataSource = reader;
reader.Close();
conn.Close();
My guess is Stored Procedure has always been off limits for SAP
applications that sits on the NetWeaver stack because of the vast database
vendors out there and the effort to cater for the different method of creating
and calling a procedure can add up to an unnecessary amount of overhead.
What SAP has given us in equivalent is the lovely function module builder
that we have all known to work with and love throughout the years. Like any
high performing, respectable RDBMS out there in the market, SAP HANA
has included the Stored Procedure function and using it with .NET is just as
simple as the
rest.
In this next example, the goal here is to change the record for Customer ID 150.
The customer name Samuel Johnson has been misspelled and it needs to be
corrected. Upon clicking on the Update Changes bu on, the .NET framework
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 8/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
will call a Stored Procedure in SAP HANA, passing in the Customer ID and
update the record using a standard SQL update command that is embedded
within a Stored Procedure. A Stored Procedure can contain logic as simple as
accep ng fields and processing it to as complex as performing specific
valida on and returning an error if the condi ons are not met.
BEGIN
END;
The change to execute Stored Procedure is to set the Hana command type
to StoredProcedure and passing in the actual name of the Stored
Procedure.
cmd.CommandText = “prcUpdateCustomers”;
cmd.CommandType = CommandType.StoredProcedure;
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 9/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
conn.Open();
cmd.CommandText = “schia_pal.prcUpdateCustomers”;
cmd.CommandType = CommandType.StoredProcedure;
param = cmd.CreateParameter();
param.HanaDbType = HanaDbType.Integer;
param.Direction = ParameterDirection.Input;
param.Value = col0;
cmd.Parameters.Add(param);
param = cmd.CreateParameter();
param.HanaDbType = HanaDbType.NVarChar;
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 10/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
param.Direction = ParameterDirection.Input;
param.Value = col1;
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Close();
In brief and not trying to include needless details on the vast .NET sample
codes which SAP has documented for the wider community, this article is
just an example of some of the basic database communication that you can
work with using Sap.Data.Hana. With the new SPS 08 client interface,
customers who are heavily reliant on the .NET framework to address
business problems can now have full SAP support when working with SAP
HANA and the ability to fully utilise all features within the product.
Alert Moderator
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 11/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
12 Comments
You must be Logged on to comment or reply to a post.
Former Member
Hello Simon,
A quick question, is it possible to call HANA Stored Procedure which accepts table
input parameter from .NET via the ADO.Net connector?. Looked at the examples but
all of them are related to a calling with single input values rather than table input
values.
My use case is that I want to send a bunch of records(ID, user, dates, etc) to a stored
procedure which insert or update these records in a DB table. It does some
validations before the insert/update operations all that logic is in the stored
procedure.
Best Regards,
Kiran
Lars Breddemann
Table typed input parameters are not supported for client calls. This
applies to all clients (JDBC, ODBC, ADO.net… ).
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 12/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
If you need to transfer a whole table content you need to look into other
options like filling temporary tables.
– Lars
Former Member
Hello Lars,
I am new to HANA.
But there are some SPs for which I need to supply a table-
type output parameter and there are some SPs where I
need to supply a table-type input parameter.
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 13/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
param = cmd.CreateParameter();
param.Direction = ParameterDirection.Output;
param.HanaDbType =
HanaDbType.TableType;
param.Value = “?”;
Kind Regards
Vijayesh
Lars Breddemann
Hey Vijayesh,
– Lars
Mohan Chandra
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 14/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
Hi, Can I have Oledb connection string like I am using for SQL server
<add name=”ERPSourceStr”
connectionString=”Provider=SQLOLEDB;Data
Source=DataSource;Initial Catalog=DatabaseName;User
ID=UserName;Password=*******; Integrated Security=SSPI”/>
<add name=”ERPSourceStr”
connectionString=”Provider=OraOLEDB.Oracle;Data Source=
(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=
(PROTOCOL=TCP)(HOST=Host)(PORT=1521)))(CONNECT_DATA=
(SID=xe)(SERVER=DEDICATED)));User ID=User;Password=******;” />
Thanks in Advance
Former Member
Hi,
i have install rel 97.0 and the binding with grid and dropdownlist don’t work, witth the
85.3 i havn’t problem.
help me!!!
Former Member
Solved,
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 15/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
i use the adapter to fill datatable and i have bind the datatablel to dropdownlist
Former Member
Hi,
I would like to make progrmming a small application on the motorola scanner , the
system is window CE6.0 and have to use vs2008 to develop, but the framework is
.net3.5 not .net4.5 in vs2008, my question is is it possible to connect to SAP hana
database using vs2008 with .net3.5, how to do with it? thank you very much!
Former Member
during debug the application there is an error “External component has thrown an
exception” on the row of HanaDataReader reader = cmd.ExecuteReader();, do you
know whats problem?
Ricardo Renteria
Edison, in that OS do you have installed the ADO .NET API for
connection to HANA database as Simon mention in Getting Started
section? Do you have the reference to Sap.Data.Hana in your code?
Ricardo Renteria
Hi Simon,
I see you use the connection string with the parameters needed to establish the
connection with the HANA DB server, but I don’t see the schema in which run the
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 16/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
queries.
If I run a query only with those parameters I get the error “the table XXX does not
exist in the schema SYSTEM”; the same occurs if I try to add the “Current
schema=MYHANADATABASE” parameter to the connection string. Despite I set the
schema, the query looks like still address the SYSTEM schema.
Mohan Chandra
Hi, Can I have Oledb connection string like I am using for SQL
server
<add name=”ERPSourceStr”
connectionString=”Provider=SQLOLEDB;Data
Source=DataSource;Initial Catalog=DatabaseName;User
ID=UserName;Password=*******; Integrated Security=SSPI”/>
<add name=”ERPSourceStr”
connectionString=”Provider=OraOLEDB.Oracle;Data Source=
(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=
(PROTOCOL=TCP)(HOST=Host)(PORT=1521)))
(CONNECT_DATA=(SID=xe)(SERVER=DEDICATED)));User
ID=User;Password=******;” />
Thanks in Advance
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 17/18
12/12/2018 Bridging the gap between .NET and HANA | SAP Blogs
Sitemap Newsletter
https://blogs.sap.com/2014/10/16/bridging-the-gap-between-net-and-hana-using-c/ 18/18