#1
  1. Huh?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Scotland, UK
    Posts
    223
    Rep Power
    11

    using ADOConnection with params set at runtime


    I am developing an application that requires users to login to a MySQL database. I am using an ADO Connection (for just now. want to change it to SQLConnection later). I have a login screen which asks the user to enter the user name, password and host name to edit boxes. i then want to take the info input here and put it into the connection string for the ADO connection. However, i am not sure how to do this.

    I think i have to use:

    ADOConnection1 -> ConnectionString = ("whatever");

    and/or

    ADOConnection -> Open ("whatever");

    The only problem is i dont know what to put into the "whatever" parts of them.

    I know i get the info from the textboxes using the code:

    UserNameEnter -> Text;
    PasswordEnter -> Text;
    HostNameEnter -> Text;

    But what do i do with it? How do i put it into the connection string?

    All help will be appreciated...Believe me... i been going crazy over this for the past few hours!!

    TIA :)
    -----------------------------------------------------------
    4dr14n
  2. #2
  3. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    29
    Try something like this:
    Code:
       AnsiString sConnect;
    
       sConnect  = "Driver={MySQL};Server=";
       sConnect += HostNameEnter->Text;
       sConnect += ";Database=test;User=";
       sConnect += UserNameEnter->Text;
       sConnect += ";Password=";
       sConnect += PasswordEnter->Text;
       sConnect += ";Option=1;";
    
       ADOConnection1->LoginPrompt = false;
       ADOConnection1->ConnectionString = sConnect;
       ADOConnection1->Open();
    The following link was written for Visual C++ but can still be a useful resource.

    http://www.codeproject.com/database/...tion%7Cstrings
  4. #3
  5. Huh?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Scotland, UK
    Posts
    223
    Rep Power
    11
    thanx!

    that helped...good link as well.

    I have now moved on to the sql connection.
    Do you think this is a better way of connecting to a MySQL databse or am i better using ADO?

IMN logo majestic logo threadwatch logo seochat tools logo