2

The current problem I'm having is an error message that it could not find file C: now I dont know what the problem is because the file is in that location. I have I tried in both .accbd and .mbd.

private static OleDbConnection GetConnection()    
{
    OleDbConnection conn = new OleDbConnection();
    String connectionString = 
            @"Provider=Microsoft.JET.OlEDB.4.0;"
            + @"Data Source= C:\Temp\F1\Docs\Expeditors Project\Table1.accbd";

    conn = new OleDbConnection(connectionString);
    conn.Open();
    return conn;
}
3
  • read the contents of file separately and use the string in connectionString Commented Jan 5, 2016 at 6:45
  • 1
    .accbd? Is that not .accdb? Commented Jan 5, 2016 at 6:53
  • Still the same error @Ripple Commented Jan 5, 2016 at 6:56

3 Answers 3

2

Do you tried another Provider? For example:

Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:\Temp\F1\Docs\Expeditors Project\Table1.accbd;
Sign up to request clarification or add additional context in comments.

1 Comment

Nice to hear that this helps
2

try \\ in Data Source Path

like below -

OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Data\test.mdb;Persist Security Info=False");

Comments

1

try this `

    `private static OleDbConnection GetConnection() throws SQLException{
        { 
    if (conn==null) 
{ 
            try{                                                                                    OleDbConnection conn = new OleDbConnection();
            String connectionString = @"Provider=Microsoft.JET.OlEDB.4.0;"
                                      + @"Data Source= C:\Temp\F1\Docs\Expeditors Project\Table1.accbd";
            conn = new OleDbConnection(connectionString);
            conn.Open();

            return conn;
        }}
    catch(Exception e){
    e.printStackTrace();
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.