.netvisual-studiomonetdbadd-references-dialog

How do you reference monetdb odbc driver for .net


I'm trying to access a monetdb from a .net application - to see if it's feasible for me to use. I have the ODBC Driver downloaded and installed on my machine (from monetDB.org). I can't add a reference to it. My assumption is that the correct file to reference is libMonetODBC.dll and that doesn't work - none of the others work either. If I try to add a reference to it I get a message - "A reference to 'C:\Program Files\MonetDB\MonetDB ODBC Driver\lib\libMonetODBC.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."

Has anyone tried this and how did you go about it? Again, my assumption is that I should be able to reference the dll, like all others, and then add a using/imports statement to use it in the app. I haven't seen a lot of documentation or other people using it from .net. MonetDB.org doesn't seem to have steps for it either other than to use it from excel or something. What am I missing?


Solution

  • 1) Add MonetDb driver to User Data Sources in ODBC Data Source Administrator

    2) Add this reference in your project

    using System.Data.Odbc;
    

    3) Create a OdbcConnection using driver name
    var monetDbC = new OdbcConnection(@"Driver={MonetDB ODBC Driver};HOST=YourServerName;PORT=50000; Database=YourDBName;UID=monetdb; PWD=monetdb;");

    4) Query to MonetDB

     var odbcCmd = new OdbcCommand() { Connection = monetDbC };
     monetDbC.Open();
     odbcCmd.CommandText = query;
     odbcCmd.ExecuteNonQuery();