Database returns null after successful connection with Devart in C#

1

I am trying to connect C# to an InterBase Database. I have downloaded and install Devart ODBC Driver for Windows and installed it. I configured the System DSN in control panel and got a Success message when I tested the connection. I generated a connection string during the process of configuring the driver which I am using to establish connection to the InterBase Database. I have managed to connect to the database in C# and also in PHP but if I try to query the database I get an error. If I display the connection information, the database name returns a null and I am suspecting that this is where the problem is but I don't know how to solve it.

Here is a link to my Devart ODBC configuration. My code in C# is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Odbc;
using System.Data.SqlClient;

namespace ConsoleApp2 {
    class Program {
        static void Main(string[] args) {

            string connString = "DRIVER=Devart ODBC Driver for InterBase;Description=testing;Data Source=127.0.0.1;Database=C:\\Program Files\\Embarcadero\\Databases\\TEST.GDB;Port=3051;User ID=sysdba;Password=masterkey";
            OdbcConnection conn = new OdbcConnection(connString);

            try {
                conn.Open();
                Console.WriteLine("Connection Information:\t");
                Console.WriteLine("\nConnection String:\t" +
                                  conn.ConnectionString);
                Console.WriteLine("\nConnection Timeout:\t" +
                                  conn.ConnectionTimeout);
                Console.WriteLine("\nDatabase:\t" +
                                  conn.Database);
                Console.WriteLine("\nDataSource:\t" +
                                  conn.DataSource);
                Console.WriteLine("\nDriver:\t" +
                                  conn.Driver);
                Console.WriteLine("\nServerVersion:\t" +
                                  conn.ServerVersion);
            }
            catch (OdbcException ex){
                Console.WriteLine(ex);
            }

        Console.ReadLine();
        }
}
}

The above code is giving me this output.

If I try to do a SELECT query on my 'USER' table in the database this is the error i get:

USERn unknown - line 1, char 15(0x80131937): ERROR [HY000] [Devart][ODBC][InterBase]Dynamic SQL Error at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Odbc.OdbcCommand.ExecuteReader() at ConsoleApp2.Program.Main(String[] args) in D:\C#\ConsoleApp2\ConsoleApp2\Program.cs:line 38

But if I enter a table name that does not exist in the database e.g. USR this is what i get:

USRle unknowne = -204Exception (0x80131937): ERROR [HY000] [Devart][ODBC][InterBase]Dynamic SQL Error at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Odbc.OdbcCommand.ExecuteReader() at ConsoleApp2.Program.Main(String[] args) in D:\C#\ConsoleApp2\ConsoleApp2\Program.cs:line 38

c#
devart
interbase
asked on Stack Overflow Aug 8, 2019 by tck • edited Aug 8, 2019 by mjwills

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0