Results 1 to 8 of 8

Thread: Connection string not working when deployed...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Connection string not working when deployed...

    I have written a VB6 application that connects to an MS Access database using the following connection string:

    Code:
    myConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myFilePath & ";"
    This works fine on the computer that has Visual Studio 6 installed on it but when I deploy this to a test machine it gives me an error when trying to connect to the database. I think it must be something to do with it not finding the provider?

    Both my test and development machine are Windows 7 x64 and both have up to FrameWork 4.0

    Any ideas?

    Thanks

    Simon

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Connection string not working when deployed...

    Did you use an Installation package to deploy on the other machine?
    Has the other machine got Access installed?
    What is the error message?
    Have you put the Database into whatever myFilePath is?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Connection string not working when deployed...

    I did install using an installer for the .Net part of my application, however for the VB6 exe I just added this to the installer as all dependencies should be install on Windows 7 to allow VB6 app to run?

    This is the error:
    http://www.ticodi.com/downloads/access_error.png

    I have checked the myFilePath and the database does exit in the path.

    The error is appearing when I execute the cnn.open command:

    Code:
    Dim Cnn As New ADODB.Connection
    Dim myConnStr As String
    
    myConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myFilePath & ";"
    Cnn.Open (myConnStr)
    Thanks

    Simon

  4. #4
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    621

    Re: Connection string not working when deployed...

    Does UAC permit you to access this path from your program? Some file paths may require administrator rights. Make sure that your program has access. One way to check is to right-click the exe and select "Run as Administrator" from the drop-down menu. Make sure that the target path is one where your program can run as a simple User.

    Dick
    Richard Grier, Consultant, Hard & Software
    Microsoft MVP (Visual Basic)

  5. #5
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Connection string not working when deployed...

    It could be that the contents of myFilePath are not causing the problem however can you please supply its exact contents when it fails.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Connection string not working when deployed...

    There are other stabs in the dark at answers at the other sites this question was cross-posted to.

  7. #7
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Connection string not working when deployed...

    And nobody knows what myFilePath contains yet!

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Connection string not working when deployed...

    Exactly.

    My guess is it fails because the file name has spaces, or may even be based on App.Path and ends up having "Program Files (x86)" within it. Simply adding quotes would take care of it, and in this case even apostrophes (') will work.

    Then UAC and file virtualization will probably be his next stumbling block.

    Or we could be all wet and the problem is somewhere else.

    The use of redundant parens on the .Open call and that trailing semicolon in the connection string don't bode well. There may be other time bombs in his code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width