开发者

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 do开发者_运维技巧ing 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜