+ Reply to Thread
Results 1 to 13 of 13

How to fetch User DSN Names and show it as a Drop Down

  1. #1
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    How to fetch User DSN Names and show it as a Drop Down

    Team,

    I got this code from one of the website, when I execute the below code the results are showing in a Message Box. I need to show it in a Drop Down Box and when I hit Connect Button, it should connect to the respective Data Source Selected.

    As I am new to VBA Programming, can Someone help me in changing this code please.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    This works for me. Basically, instead of building a string to display in a message box, I write the results out to a sheet called Lookups. This, in turn, is overlaid with a named dynamic range called List_Connections and this is used as the source for a list type data validation on the Dropdown sheet. The changed code is shown in red.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    Ooops, just noticed that I only answered half the question. I'll get back to you.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    I have some follow on questions. What is the purpose for changing the connection? Also are all your connections of the same type? I have a mix of Access, Excel, ODBC to Oracle databases and several text file directories. Each has a different connection string.

    Then after you connect to the source, what are you going to do with it, do you have a SQL string?

    It would help if you could define the bigger picture.

  5. #5
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to fetch User DSN Names and show it as a Drop Down

    Hi,

    Thanks for your response & big Thanks to you!

    In my User DSN's I also have 'MS Access Database' and 'dBASE File' and 'Denodo_DEV'. I am not sure what is connection string is

    For Denodo_DEV I tried to record the Macro. so when I connect through Data --> Get External Data --> Denodo DEV

    The code it generated is. Please let me know if it helpful. For Other ones MS- Access and dBase Files those are by Default DSN's which are not added by me.

    Please Login or Register  to view this content.

    Thanks!
    Kiran

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    Each type of connection has a different format. We are missing part of the puzzle here: we have the connection name, we do not have the connection type. We'd need that information in a case statement to build a proper connection string.

    If you can tell me what the end result is, there may be alternatives.

  7. #7
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to fetch User DSN Names and show it as a Drop Down

    The End Result is.

    I just want to compare Source & target Queries.

    Example

    1) Lets say we have Two Databases

    a) Source Database
    b) Target Database

    2) I need to Compare Source Table Data with Target Table Data

    3) For Comparison, I will create Source Query & Target Query and Store it in two file

    4) We have to create User Form

    a) Text Box 1 - with Browse Button to select the Source Query File
    b) Drop Down 1 - to select Source DataSource - which should be the Drop down of User DSN's
    c) Text Box 2 - with Browse button to select the Target Query File
    d) Drop Down 2 - to select Target DataSource - Which should be the Drop down of User DSN's
    e) Now we have to compare with Source Query File with Target Query file based on Data sources selected in Drop down's.
    f) In a separate sheet we have to populate the Unmatched Records


    Thanks!
    Kiran



    a) Text Box1 with browse Button.

    b) Text Box 2

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    OK - got it. I'll be out of the office until later next week.

    I already have a system for rewriting SQL on the fly. I am fairly certain that once I know the type of connection I can substitute the specific database in. Figuring out how to find the type of connection will be the issue. I might tear into that initial code and see if it can provide type as well.

  9. #9
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to fetch User DSN Names and show it as a Drop Down

    I will ask the Database Team here.

    Also, can you please check if the below URL is helpful in getting the info.

    https://community.denodo.com/tutoria...ect2odbcclient

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    I dug into the original code. It reads the windows registry, so I followed the path and the registry entry they use does have the driver information. However, I don't know how to extract it ... yet. This could be a bit of a research project.

  11. #11
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    I made some headway and am now at the next impasse. The attachment shows the connections on my machine. There would be no issue on making a connection string for the oracle databases. However for the rest of them, you have to know the location of the text file, spreadsheet or access database for it to happen. There is a default dir for the text files, but not for Access or Excel.

    So, in addition to providing the connection name, if the connection is one of these other types, then you will also have to provide the full pathname to the Excel or Access file or the directory that contains the text files.

    Is this what you had in mind?
    Attached Images Attached Images

  12. #12
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to fetch User DSN Names and show it as a Drop Down

    Hello,

    I am connecting to Denodo / Netezza through Postgress and the Driver (Postgress DLL file) is there in the below path.

    PATH

    C:\Program Files (x86)\psqlODBC\0905\bin\psqlodbc30a.DLL

    and I added User / System DSN as in the attached file and for PORT NUMBER and Server Name please refer to the below code.

    I am still need to get the info on Connection Name. Database team said the Connection Name is the Name what we give in creating DSN.


    Thanks!
    Kiran
    Attached Images Attached Images

  13. #13
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to fetch User DSN Names and show it as a Drop Down

    Is this the only kind of database to which you wish to connect? Also can you provide a sample connection string.

    Also run the macro in the attachment and show me your results. We may be closing in on this.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Fetch data based on Drop down selection
    By Sanjibghosh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2017, 02:25 AM
  2. [SOLVED] INDEX + MATCHING to show user names with rules
    By guy13 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-15-2015, 11:26 AM
  3. Need macro to fetch value when a user selects a checkbox
    By santnair0599 in forum Excel General
    Replies: 2
    Last Post: 05-30-2015, 01:04 PM
  4. Show Workbook Names in Combobox Drop Down list
    By champ007 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2014, 03:47 PM
  5. How to fetch first few values or names from excel column
    By meetvivek72 in forum Excel General
    Replies: 5
    Last Post: 02-13-2014, 06:48 AM
  6. My user defined function doesn't show up in autocomplete drop down menu
    By wlan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2010, 09:56 AM
  7. [SOLVED] Fetch list of table names in access to a record set
    By Prashantha Weerakoon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2005, 08:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1