You might have an exception thrown when you execute your Visual Studio project and OdbcConnection is being opened with an error message indicating that there is an architecture mismatch between the application and the DSN referred. Odbc Exception due to Architecture Between DSN Driver and Application TextBox1.Text = TextBox1.Text rowData RowData = rowData " " reader("TABLE_NAME") "select top 3 * from ""PUBLIC"".""M_TABLES"" where schema_name = ? ", "MYHDBUSER")ĭim rowData As String = reader.GetString(0) TextBox1.Text = "SAP HANA Database Connection is successful!" I also wanted to attach VB.NET codes that programmers can use for SAP HANA database connection using a Windows Forms application built in a Visual Studio solution.īelow are sample VB codes for developers to use in HANA database connection projectsĬonnectionString = "DSN=KodyazHANADb SERVERNODE=:30815 UID=myHDBUser PWD=myDBUserPwd DATABASENAME=myDBName"ĭim conn As New OdbcConnection(connectionString) VB.NET Code for SAP HANA Database Connection using ODBC in Visual Studio When I execute above code within my sample Visual Studio C# project, I got following outcome as result of the application. So I just wanted to show the two ways a column value can be read (either using column index or column name) Within the loop, first column value is fetched as well as TABLE_NAME column. Reads returning data set within in WHILE loop. TextBox1.Text = textBox1.Text rowData Ībove C-Sharp code connects to SAP HANA database. Using (OdbcDataReader reader = cmd.ExecuteReader()) "select top 3 * from \"PUBLIC\".\"M_TABLES\" where schema_name = ? ", "MYHDBUSER") Please do not confuse database name with catalog name If you don't know the database name, you can query M_DATABASES system view to find out the name of your HANA database. ServerNode details, the HANA Database server and port number was already used in the definition of the ODBC connection createad in SYSTEM DSN tab. Then define a string variable for connection string as follows: Within sample project code, first import namespace " " I have already described how to download SAP HANA Database Client and install for HDBODBC driver.Īfter SAP HANA Database Client is installed and a SYSTEM DSN is created via ODBC Data Sources, C-Sharp or VB.NET developers can continue with sample program code below. The related ODBC connection should be created using the HDBODBC driver which is provided by SAP. First of all, to connect to a SAP HANA Database developers should create a SYSTEM DSN entry.Īs I documented in tutorial Connect SAP HANA Database from SQL Server using Linked Server, programmers can define an ODBC connection with Data Sources (ODBC) from Administrative Tools.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |