0
votes

i'm trying to use oledb connection, while using csc.exe compiler. But somehow code doesnt give error on .net ide, but gives error on csc.exe.


Code:

using System;   
using System.Data.OleDb;

class vtBaglanti
{   
    static void Main()
    {
        string kaynak = "Provider=Microsoft.ACE.Oledb.12.0;Data Source=okul.accdb";

        OleDbConnection baglanti = new OleDbConnection(kaynak);    
        baglanti.Open();

        Console.WriteLine("VT Bağlantısı Sağlanmıştır.");
    }
}

Error :

İşlenmeyen Özel Durum: System.InvalidOperationException: 'Microsoft.ACE.Oledb.12 .0' sağlayıcısı yerel makine kayıtlı değil.
konum: System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionSt ring constr, DataSourceWrapper& datasrcWrapper) konum: System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) konum: System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnection Options options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbCo nnectionPool pool, DbConnection owningObject) konum: System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection (DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOpt ions userOptions) konum: System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnec tion owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOpt ions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) konum: System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInterna l(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompl etionSource1 retry, DbConnectionOptions userOptions)
konum: System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnect ion outerConnection, DbConnectionFactory connectionFactory) konum: System.Data.OleDb.OleDbConnection.Open() konum: vtBaglanti.Main()

1
Use english in your visual studio !mybirthname

1 Answers

0
votes

the error means that The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. It has been discussed before. You need to install ACE components on your computer. You will need to match the CPU architecture of ACE to the CPU architecture of the version of MS Office you have installed.

This answer has the list of ACE distributions for you to choose from.

The below 2010 version of ACE should be enough in most cases:

Microsoft Access Database Engine 2010 Redistributable

PS. Welcome to StackOverflow, please check the Tour to get started with asking, answering, voting for posts etc.