Skip to Content
Author's profile photo Alvaro Tejada Galindo

And along came .NET

This last weeks I have been blogging a lot about integration of 3rd party tools with SAP HANA. Like Python, R, PowerBuilder and Euphoria. So, the next natural step for me was make the same using .NET

This might sound repetitive, but it’s been a long time since I used .NET, actually I have never use it too much, just for some small personal projects but nothing really big.

First I did was to download the Visual Studio 2012 Express for the web, meaning that I will present some ASP.NET code (VB.NET style).

We must create a new project and call it “HANA_NET”

HANA_NET_01.png

And then create two Web Form’s…call them WebForm1.aspx and WebForm2.aspx as it’s the default.

HANA_NET_02.png

At first, I thought about using a JDBC connection, but then realized that Microsoft wouldn’t provide that, so next choice was ODBC…but…I discover something kind of weird…ODBC is not provided by default…

HANA_NET_DATASOURCE.png

So…we’re going to do everything by code…lovely isn’t it?

Second thing I discovered is that the ISS Express Web Server is 32 bits by default, so working with Windows 7 and having 64 bits SAP HANA drivers wasn’t really helpful…after some Internet browsing, I found out that ISS Express is provided in both 32 and 64 flavours but you get 32 bits by default and there’s no easy way to override it…so…the solution is…launch it from it’s source…

HANA_NET_08.png

With this little trick, we’re not going to have any problems at all…

Let’s create an ODBC connection for SAP HANA, which must by the way exist on System DNS, otherwise it’s not going to work. Again, more 64 bits problems.

HANA_NET_ODBC.png

Now…we can start coding…go to the Web.config file and double click on it to modify it code…

HANA_NET_03.png

That would tell ASP.NET that we want to use that DSN.

On the WebForm1.aspx create this layout (Yep…my design skills are under water)…

HANA_NET_04.png

Right click and select View Code…

HANA_NET_05.png

Go to the WebForm2.aspx and write this code (No layout here as we need to add some thing by code)

HANA_NET_06.png

Again, go to the View Code option…

HANA_NET_07.png

With our IIS Express server up and running, we only need to the execute our webpage

HANA_NET_09.png

HANA_NET_10.png

That’s all folks…a simple example showing that .NET can speak SAP HANA too…

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Derek Fox
      Derek Fox

      Hi Alvaro

      Interesting blog about .NET and HANA.

      A question, can one use .NET to write data back to HANA?

      Regards

      Derek

      Author's profile photo Former Member
      Former Member

      Hello Alvaro

      Thanks for the great article on ASP and HANA.

      How did you create the System DSN?

      Can you please share a link or details.

      cheers

      Vinod

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author

      Vinod:

      On Windows it's pretty easy...just go to:

      Control Panel --> Administrative Tools --> Data Sources (ODBC) --> System DSN.

      I'm not sure what the difference between User and System DSN...because I work as Administrator...but somehow some programming languages needed like that 🙂

      Greetings,

      Blag.