Results 1 to 4 of 4

Thread: How to make ODBC connection through combo selection

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Location
    Bhutan
    Posts
    26

    How to make ODBC connection through combo selection

    I'm using VB.6 & SQL server 2000. Problme is I have two data base and I want to work it on one plat form. I've connected to sql server through ODBC connection but problem is..... how can i make connection to either of Data Base through combo selection so that when i select particular database it connect to it.

    Here is my code that connection to dbase:
    Public Const gConnection = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=Description=LSSCE;DRIVER=SQL Server;SERVER=SONAMG\BBE;UID=sa;APP=Visual Basic;WSID=SONAMG;DATABASE=BBE;Network=DBMSLPCN"

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Exactly what you need to do depends on the location of the two databases, and the server types.

    You imply both databases are SQL Server, which makes it easier. If they are on the same server it's easier. If they have the same login details (or no login required) then it's easier again.

    If those assumptions are true then this should work:

    VB Code:
    1. Public gConnection as String
    2.  
    3. ...
    4.  
    5. combo1.additem "BBE"
    6. combo1.additem "other database"
    7.  
    8. ...
    9.  
    10. gConnection = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=Description=LSSCE;DRIVER=SQL Server;SERVER=SONAMG\BBE;UID=sa;APP=Visual Basic;WSID=SONAMG;DATABASE=" & combo1.text & ";Network=DBMSLPCN"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Location
    Bhutan
    Posts
    26
    Thank you.... It really worked;
    Can this type of selecting database be done to Crystal report also

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Crystal is a nightmare for many issues, this is one of them...

    check out the crystal web site and the specialist crystal forums to find out how to do it.

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