ms access data source for connection with .net RRS feed

  • Question


    what should be the ms access data source for connection with .net 2005 using oledbconnection .

    i am writing


    "Provider=microsoft.jet.OLEDB.4.0;Data Source=/C:/Documents and Settings/bb/My Documents/db1.mdb;Integrated Security=SSPI";



    when I try to open this connection I get the error "multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." what is wrong with this code???

    Thursday, December 4, 2008 2:55 PM

All replies


    Integrated Security=SSPI is not a valid parameter when connecting to an Access database. The Windows user running the application needs to have at least read permission on the database file. But it is not possible to define permission for the database based on Windows credentials. If you have secured the database with Access user credentials then specify them in the connectionstring, e.g.


    User Id=admin;Password=;


    You may also specify the location of the Access system database containing the user information:


    Code Snippet
    Jet OLEDB:System Database=system.mdw;



    (I put the above parameter sample into a code sample to avoid automatic  conversion of ": S" without the blank into a smiley.)


    And last but not least don't start the Data Source parameter with a forward slash. This will cause an invalid file name. Forward slashes seem to be ok to separate the parts of the file path. But it is more common to use a backslash. In C# you can add the prefix @ to the connection string to avoid that backslashes are treates as start of an escape sequence:


    @"Provider=microsoft.jet.OLEDB.4.0;Data Source=C:\Documents and Settings\bb\My Documents\db1.mdb;"


    Hope this helps.


    Ralf Ksciuk-Haf



    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, December 4, 2008 9:30 PM