Sql Server Error: No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
Connection string to SQL server Express
I am having trouble with connection strings from VS 2005 to an SQL Express database.
I have an application now running using an Access Database and OLEDB. I wanted to convert my data from Access to SQL Server. All Queries are handled by a module that I wrote that accepts an SQL statement and returns a DataTable. I would like to use this same technique with an SQL Server database
This is the code from the module
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
To see if this would work I used the northwind database. I added it to my Project and I was able to retrieve data from the table using a table adapter. I built the table adapter by following the tutorials and was able to populate tables and fill a GridView Control.
The connect string shown in the table adapter was:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
I tried to connect using this and got the following error:
'Error message -- "An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'." String
I then tried the connection string with the provider information
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
And got the following error message
'"No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21)." String
I also tried to give a full path to the database file and failed with the same error message:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
'"No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21)." String
I have looked through this forum and tried many other combinations and can't get it to work. Any Ideas of what the string should be.
Thanks.
The Soulation Is :
If you are connecting to sql you should be using the sqlclient class instead of OleDb. Try it like this:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)