简体   繁体   中英

Data source name not found and no default driver specified

I'm getting this error when trying to open the connection in code as follows:

 string queryString = "Insert into Table;

        OdbcConnection connection = new OdbcConnection();
        connection.ConnectionString = Settings.Default.STIMConnectionString;
        OdbcCommand command = new OdbcCommand(queryString,connection);
        connection.Open();
        command.ExecuteNonQuery();

My Appconfig is as follows:

 <add name="WindowsFormsApplicationTransducer.Properties.Settings.STIMConnection"
  connectionString="Provider=Microsoft.ACE.OLEDB.12.0; Data    Source=&quot;D:\Development\SS Observer II Decoder.mdb&quot;" />

What am i doing wrong?

Since you are using the OdbcConnection, I think you need to include the "Driver" information in your connection string.

Data Source is not a valid connection string property. ODBC originally used a data source name, or DSN=dsnname , where the DSN was configured separately on the system. However you can alternatively specify the driver and driver-specific parameters, which in the case of the Microsoft Access driver is at the minimum the file name: Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\Development\SS Observer II Decoder.mdb .

See http://connectionstrings.com/ to see what you need to have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM