Hi
I have included - using Sap.Data.Hana; How to make connection to Sap b1 Hana database.
Thanks
Hi
I have included - using Sap.Data.Hana; How to make connection to Sap b1 Hana database.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 5, 2025, 2:20 AM EST
Hi @Ramco Ramco,
To connect to the SAP B1 HANA database using the
Sap.Data.Hananamespace in .NET, you will need to utilize theHanaConnectionclass. Below is a concise example demonstrating how to establish this connection:using Sap.Data.Hana; using System; class Program { static void Main() { string connectionString = "Server=your_server;Port=30015;UserID=your_user;Password=your_password;Database=your_database;"; using (HanaConnection connection = new HanaConnection(connectionString)) { try { connection.Open(); Console.WriteLine("Connection to SAP B1 HANA database established successfully."); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } finally { connection.Close(); Console.WriteLine("Connection closed."); } } } }In this example, replace
your_server,your_user,your_password, andyour_databasewith your actual database credentials. This code snippet opens a connection to the SAP B1 HANA database, handles exceptions, and ensures the connection is closed properly.