Page 2 of 2 FirstFirst 12
Results 41 to 48 of 48

Thread: [RESOLVED] This code won't open database connection in vs2008, it does work in vb6

  1. #41

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    yes sir, that same connection string works in vb6 , no error, connects to the server

    Con1.ConnectionString = "Provider=MSDASQL.1;DRIVER={MariaDB ODBC 3.1 Driver};DATABASE=;SERVER=localhost;UID=root;PASSWORD=root;PORT=3308;OPTION=34;"
    Con1.Open
    'if no error
    NoError = True

    image showing it debug passes the con1.open line
    Attached Images Attached Images  

  2. #42
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,547

    Re: This code won't open database connection in vs2008, it does work in vb6

    So what happens if you use that exact same connection string in the other app? Just hard code it, rather than building it.

    Also, when you installed the odbc driver did you install a 32bit or 64bit version?

    If you only have a 32bit version it might be failing if your app is running as 64bit. If that is the case either install a 64bit odbc driver, or set your app to run as 32bit (x86) in your project properties.

  3. #43

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    Quote Originally Posted by PlausiblyDamp View Post
    Have you installed a MySql odbc driver?
    Most assuredly
    MariaDB and Mysql ODBC drivers. They work in vb6 or I would have no odbc working in the program at all.
    This has to do with configuration of vs2022
    Attached Images Attached Images  

  4. #44

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    Quote Originally Posted by PlausiblyDamp View Post
    So what happens if you use that exact same connection string in the other app? Just hard code it, rather than building it.

    Also, when you installed the odbc driver did you install a 32bit or 64bit version?

    If you only have a 32bit version it might be failing if your app is running as 64bit. If that is the case either install a 64bit odbc driver, or set your app to run as 32bit (x86) in your project properties.
    interesting idea there... is there a 64 bit driver or are they all 32 bit?

    I know I have 32 bit drivers installed

    Where to set app to run as 32 bit?

  5. #45

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    Quote Originally Posted by PlausiblyDamp View Post
    So what happens if you use that exact same connection string in the other app? Just hard code it, rather than building it.

    Also, when you installed the odbc driver did you install a 32bit or 64bit version?

    If you only have a 32bit version it might be failing if your app is running as 64bit. If that is the case either install a 64bit odbc driver, or set your app to run as 32bit (x86) in your project properties.
    WELL YOU FIGURED IT OUT!
    It connects now after installing a MariaDB 64 bit driver

    bother me that the name for the 32 bit and 64 ODBC drivers are the same name, somehow it know what to do!

  6. #46

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    There is a difference between vb6 and vs2022 regarding the connection string.
    In vs2022 with the MariaDB 64 bit ODBC driver, it must include the database name.

    In vb6 with 32 bit ODBC driver, you can leave that name out and it connects.

    You know in the windows command prompt you can connect to the servers without specifying a database name.
    All you need is user, password, port and it connects you to the server.

    Then at the server prompt, you type use databasename, return key, and it will use that database name.
    So I think this is odd behavior at least to me.

  7. #47
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,809

    Re: This code won't open database connection in vs2008, it does work in vb6

    Quote Originally Posted by sdowney1 View Post
    I can simply try the mysql example on the mysql page I suppose.
    You didn't answer my question. I was trying to provide you with an ADO.NET example of populating an in-memory DataTable with data from a MySQL table, but the code you pasted in appears to still be legacy code (namely ADODB).

    If you wanted to use ADO.NET (because its 2024) and MySQL (because its free), then you should do the following:
    1. Install MySql.Data from your NuGet manager: Right-click on your project in the solution explorer, click on Manage NuGet Packages, browser for MySql.Data, select the library and click install
    2. Use the code from post 12
    3. Import the namespaces as described in post 16 or fully qualify the classes


    I would highly discourage using ADODB and On Error GoTo, this is legacy syntax and you will be hard pressed to find much assistance with it.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  8. #48

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    528

    Re: This code won't open database connection in vs2008, it does work in vb6

    I was thinking maybe there is an issue with the 64 bit ODBC MariaDB driver.
    When I modeled this program 20 plus yrs ago, I did so just like people do today in connecting to a server in a command prompt window.
    You connect to the server using user, password and sometimes port.
    You never need a database name to connect to a server
    Once connected you either create a database or select one to work on.

    So if you are forced to include a database name in a connection string, that can't possibly work on a fresh install where there are no databases or where database names are unknown...

    The way it should work in a program,
    1. make a server connection
    2. create a database or select one
    3. work with tables in a database.

    Right now that is impossible regarding the 64bit ODBC driver and vs2022

    I need to see how it works with mysql 64 bit drivers on their server and running the program as 32 bit.

    EDIT, I figured it out, it works as expected connects with no DB name needed.
    In my testing I had left out a semicolon at the end of the databasename field, as in

    "DATABASE=" versus should have been "DATABASE=";

    So very happy so far!
    Last edited by sdowney1; Apr 22nd, 2024 at 05:03 PM.

Page 2 of 2 FirstFirst 12

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