4

I am trying to connect to NexusDB using ODBCConnection in System.Data.Odbc namespace. I am able to run the same piece of code on my machine using .NetFramework 4.6.1 console app which is working. I have NexusDB V3.09 Driver installed on my machine.

Below is my code :

string conns = "DRIVER={NexusDB V3.09 Driver};Transport=TCP;SERVER=NexusDB@ipAddressValue;PORT=16000;DataBase=DBName;";

        using (var conn = new OdbcConnection(conns))
        {

            string maxNumberQuery = "SELECT MAX(NUMBER) FROM CLIENT";
            OdbcCommand oCmd = new OdbcCommand(maxNumberQuery, conn);
            conn.Open();
            result = (int)oCmd.ExecuteScalar();

        }

When I try to use the DotNetCore console app to open a connection, I get this error:

[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

TallTed
  • 9,069
  • 2
  • 22
  • 37
Mahesh
  • 823
  • 1
  • 11
  • 29
  • What does "unable to open a connection" mean? Are you getting an error message? What is it? – TallTed Dec 28 '17 at 14:45
  • ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified – Mahesh Jan 02 '18 at 06:25
  • Are you running both `.NetFramework 4.6.1` and `DotNetCore` console apps on the same machine? Are both of these running as the same bitness as the Nexus ODBC driver? (Note, these connections invisibly go through the Microsoft ADO.NET Provider for ODBC. Why are you not using the [NexusDB ADO.NET Provider](https://www.nexusdb.com/support/index.php?q=node/529)?) – TallTed Jan 02 '18 at 14:49
  • Yes i am running both on same machine.I targeted both applications to any(32 and 64) and i can see my specified NexusDB V3.09 Driver in both 32 and 64 system DSN settings. For investigating i can not download trial version NexusDB ADO.NET Provider for free. – Mahesh Jan 03 '18 at 06:02
  • Can you configure and test an ODBC DSN for this connection, and then change your code to use a much simpler connect string (like `"DSN=your_dsn_name"`)? If that works, it'll be much easier to move forward. Failing that, I suggest turning on ODBC tracing, and looking to see what's happening there, which results in the reported error message. (Note - we're getting well beyond Q&A here.) – TallTed Jan 03 '18 at 15:26
  • I tried adding DSN name in multiple ways(i mean formats) but with no luck. – Mahesh Jan 04 '18 at 14:48
  • 1
    Your comments (i.e., your responses to my questions) should be worked into your question. "multiple ways(i mean formats) but with no luck" tells us nothing. We need to know exactly what you tried, with exactly what results. Also, and again, ODBC Trace output is very likely to be necessary to solve this one. – TallTed Jan 04 '18 at 15:13
  • I am sorry for that. I have tried below connection strings, string conns = "DRIVER={NexusDB V3.09 Driver};Transport=TCP;DSN=MyDSNName;SERVER=NexusDB@ipAddressValue;PORT=16000;DataBase=DBName;"; string conns = "DRIVER={NexusDB V3.09 Driver};Transport=TCP;DSN={MyDSNName};SERVER=NexusDB@ipAddressValue;PORT=16000;DataBase=DBName;"; – Mahesh Jan 05 '18 at 05:43
  • And also can u please let me know how i can do ODBC tracing. – Mahesh Jan 05 '18 at 05:45
  • (1) Please click EDIT on your question, and add the additional details to your question, rewording as may be necessary for clarity. Back-and-forth in comments is not appropriate for this site. (2) [Microsoft documents ODBC tracing fairly well](https://www.google.com/search?q=site%3Amicrosoft.com+odbc+trace). – TallTed Jan 05 '18 at 15:38

0 Answers0