Results 1 to 7 of 7

Thread: [RESOLVED] connection string created in new connection string wizard wont work in program

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2018
    Posts
    26

    Resolved [RESOLVED] connection string created in new connection string wizard wont work in program

    I am trying to upgrade a Visual Basic 6 program to a more modern look. I didn't write the original program. The program uses .mdb Access Database that is password protected. I know .mdb is old but really don't want to redo 35 database tables if I don't need to. Plus not everyone will upgrade to the new program so I only want to provide updates to one Database for both programs. I went into the tools and then new connection, it creates a connection string and it works when I hit the test button. Copied it and placed it into my program where I get an error...
    .................................................................................................... ................
    'System.Data.OleDb.OleDbException' occurred in System.Data.dll

    Additional information: Could not find file 'C:\Test Data\County Hunter - K8EMS.mdbJet OLEDBatabase Password =
    .................................................................................................... ..............................................................................................

    the connection string is
    .........................................................................
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Test Data\County Hunter - K8EMS.mdb";Persist Security Info=TrueproviProvider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Test Data\County Hunter - K8EMS.mdb";Persist Security Info=True=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Test Data\County Hunter - K8EMS.mdb"

    .................................................................................................... .............................................................
    When I look at the error it say's the semi colons in the string are what is keeping it from working. What am I doing wrong I am LOST ?

    Any help would be appreciated, as I am not a professional programmer just enjoy programming for my main hobby Ham Radio.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: connection string created in new connection string wizard wont work in program

    You have two connection strings (or possibly three) packed together in there. Take a look at this point:

    ;Persist Security Info=TrueproviProvider=

    Persist Security Info = True

    is where that should end. There is no such thing as Trueprovi, so the provi part appears to be the beginning of Provider, but then you DO have Provider. Of course, you already had provider as the very first element.

    So, there appears to be two complete connection strings, then a third one wrapped around the second one. You have the Provi part of the word Provider, but I don't see the der part of it, but the rest of it is right in here:

    True=Microsoft

    That True is the end of the second complete connection string, the equals sign is the equals sign of that Provider for the third connection string (though the letters der appear to be missing), and all that follows is pretty much the rest of that third connection string other than the Persist Security part, which you may not have needed.

    So, the solution is to delete everything after the True part of: TrueproviProvider
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2018
    Posts
    26

    Re: connection string created in new connection string wizard wont work in program

    Ok Valid point must have screwed up on copy and paste on that on. SORRY

    But I redid the connection string and got this.....Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Test Data\County Hunter - K8EMS.mdb";Persist Security Info=True



    and got this error message...An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

    Additional information: Not a valid password.

    I know I have the right password as a it tested good. Also if I get out of Visual Studio and open the database the password works.

    I guess my question is shouldn't the password be passed in the connection string.

    I have been going thru sql book and Visual basic 2015 book and find no mention of opening a password protected database. I haven't found it on the internet either but that could be just not asking the right question. I really could use some help.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: connection string created in new connection string wizard wont work in program

    This is the site that I use for that kind of question:

    https://www.connectionstrings.com/access/

    Note the example with a password. I'd say that you are right that it should be there, and that's the one you want.

    Also, to avoid a further question, go into Project |Properties, look on the compile tab, and make sure that you are targeting x86 rather than the default AnyCPU. The Jet DB engine doesn't have a 64 bit version, and AnyCPU acts a bit funny in that case, cause, if you are on a 64 bit system, it will look for the 64 bit driver, not find it (cause it doesn't exist), and fail. By targeting x86, you won't have that issue, and there really isn't a downside to that.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2018
    Posts
    26

    Re: connection string created in new connection string wizard wont work in program

    Thanks for the help again Shaggy Hiker.
    Now I get the error that Jet 4.0 is not registered on my computer.
    I have saved that web sight for further reference.
    Rebooted the computer and this error went away but I get this new error
    ..........................
    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

    Additional information: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
    .....................................
    Not sure what this is or where to find it.

    I hate to be a pain, your help is greatly appreciated and helps the frustration level to decrease.

    Thanks for all the help so far.
    Last edited by MikeDelke; Feb 17th, 2018 at 07:22 PM.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: connection string created in new connection string wizard wont work in program

    Well, that one I have never seen. A quick search turned up this thread:

    https://social.msdn.microsoft.com/Fo...forum=winforms

    I'm not too keen on that site, as the organization strikes me as being bizarre, but there are some suggestions in there you might want to try out.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2018
    Posts
    26

    Re: connection string created in new connection string wizard wont work in program

    Thanks so much for all your help Shaggy Hiker. I decided I just needed to bite the bullet and I made the Database's Access.accdb so I could use Ace12.0 and that seems to have eliminated all the errors to this point. Now all I need to do is devise a way to convert the mdb to accdb, in an ongoing way so that the old program can use the mdb and the converted program can use the accdb versions. Might be more work than I was hopeing for but my problem hey. ( the price we pay for modernization.

    Again THANK YOUR for all your help, I am sure there will be more questions

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