Time to Complete
10 Min.
A tutorial that explains how to setup a sample database in Visual Studio using the ado.net data provider
Setup: This tutorial assumes that you have followed the How to Install SAP HANA 2.0, express edition Clients tutorial to install the HANA, express edition client software.
Setup: You must have Microsoft Visual Studio 2010 or later installed on your computer.
A Microsoft visual studio project can connect to SAP database using SAP HANA Client that has data providers for Microsoft .NET Framework. In this How-To you will use a demo database table setup project to learn about connecting to SAP HANA database servers from Visual Studio.
In this tutorial, you will use the data provider to set up sample database tables, views, and procedures.
Access the sample projects for the data provider, download the appropriate project.
Start Microsoft Visual Studio.
Click File » Open » Project/Solution.
Browse to Documents\SAP\Projects\DemoSetup
and open the DemoSetup.sln
project.
By Default, Sap.Data.Hana for .NET
data provider reference will be added after importing the project as shown below. This data provider will be located in SAP HANA Client installation path.
Click Debug » Start Without Debugging or press Ctrl+F5 to run the project.
In the Connection String field, type a valid connection string and click Connect to connect to an SAP HANA database server. The example given below connects to a database called HXE
assigned to the parameter databaseName
. HXE
is the default tenant database the server connects to on port 3< instance number >15
.
Server=hana-server:30015;databaseName=HXE;UserID=system;Password=manager
, connects to an SAP HANA database server with the indicated host name or its IP address, port (usually 3 followed by instance number then 15), a database, user ID, and password.
You can also connect to the database using ODBC driver. For example,
Driver={HDBODBC};UID=system;PWD=manager;SERVERNODE=hana-server:30015;databaseName=HXE
, Note that driver can beHDBODBC
orHDBODBC32
depending on whether your application is 64 bit or 32 bit respectively.
If your credentials are correct, then the .NET application connects to your SAP HANA database server. The list-box area is filled with the names of any existing tables, views, or procedures belonging to the DEMO schema.
Example Below.
Click Create demo objects.
The application reads and executes a script of SQL statements contained in a file located in the indicated Script file path
.
If the execution of the script was successful, then the list-box area is filled with the names of tables, views, or procedures belonging to the DEMO schema.
Click Disconnect to disconnect from the SAP HANA server and close the window to shut down the application.