September 1, 2010

No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21)


I am having trouble with connection strings from VS 2008 to an SQL Express database.


The connect string shown was this:

<add key="sClassifiedsDBConnectionString" value="Data Source=LAKSH\SQLEXPRESS;Initial Catalog=ClassifiedsApp;Integrated Security=True;Persist Security Info=False;Connect Timeout=120"/>



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



<add key="sClassifiedsDBConnectionString" value="Data Source=LAKSH\SQLEXPRESS;Provider=SQLOLEDB;Initial Catalog=ClassifiedsApp;Integrated Security=True;Persist Security Info=False;Connect Timeout=120"/>



And got the following error message


'"No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21)." String


This error occur because the OleDbProvider needs you to inform the provider it will use in order to use Integrated Security, and by putting true in this parameter you are not really telling which provider it should use.


Thus, in order to use Integrated Security with OleDb, just inform that it should use the Security Service Provider Interface (SSPI) in the connection string:



<add key="sClassifiedsDBConnectionString" value="Data Source=LAKSH\SQLEXPRESS;Provider=SQLOLEDB;Initial Catalog=ClassifiedsApp;Integrated Security=SSPI;Persist Security Info=False;Connect Timeout=120"/>





Now it works!



Note: This is a general resolution , I solved this with respect to classifieds_aspnet 

1 comment:

  1. Great post, helps me so much
    Tank's

    ReplyDelete