Home > Enterprise >  System.NotImplementedException: OleDb is not implemented
System.NotImplementedException: OleDb is not implemented

Time:09-17

I'm trying to get the ole db example running on linux with mono, but I get the error message: System.NotImplementedException: OleDb is not implemented. The problem is that I need oledb, because the target is an external application where I cannot change the source code and there I am getting the same error.

Is there a way to get oledb running?

mono version: 6.12.0

This is the example code from the mono page:

using System;
 using System.Data;
 using System.Data.OleDb;
 
 public class Test
 {
    public static void Main(string[] args)
    {
        // there is a libgda PostgreSQL provider
       string connectionString =
          "Provider=PostgreSQL;"  
          "Addr=127.0.0.1;"  
          "Database=test;"  
          "User ID=postgres;"  
          "Password=fun2db";
       IDbConnection dbcon;
       dbcon = new OleDbConnection(connectionString);
       dbcon.Open();
       IDbCommand dbcmd = dbcon.CreateCommand();
       // requires a table to be created named employee
       // with columns firstname and lastname
       // such as,
       //        CREATE TABLE employee (
       //           firstname varchar(32),
       //           lastname varchar(32));
       string sql =
            "SELECT firstname, lastname "  
            "FROM employee";
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = (string) reader["firstname"];
            string LastName = (string) reader["lastname"];
            Console.WriteLine("Name: "  
                 FirstName   " "   LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }

CodePudding user response:

Basically oledb comes from .Net Installation package for visual studio since you are running it on linux i think you should find an oledb package for you linux version and then try importing that to your project by add referencing and then try implementing your code

or you can check if Sql is working instead of oledb try to replace the work OleDB with Sql and lets see if that works for you or not

CodePudding user response:

OLE DB is a Windows-specific technology. On other platforms, use ODBC instead.

  • Related