Results 1 to 15 of 15

Thread: allow user to select database Server

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    97

    allow user to select database Server

    My application can use both Oracle and SQL Server as back end.
    On the first run, it prompts the user to select a DB Server. Based on the selected DB Server, it will load the appropriate Data access components.

    For example, I want to check if there is an Oracle (or SQL Server) Instance running -If it is running, I can use the instance to create my database etc. even if the instance is not running I should be able to retrieve the details of installed DBases on the Machine-that's what utilities like TOAD or TORA do.

    My problem is, how do I enumerate available DB servers on a system. They can be either Oracle(any version) or SQL server, so that I can present a drop down list box of available DB servers for the user to select from.

    I don't want to just enumerate the DSNs available on the machine. The problem is complicated since these databases can be installed on remote computers in a networked environment.

    Any help is highly appreciated
    Last edited by tvssarma; Sep 25th, 2004 at 07:37 AM.
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Dont quote anyone if you can help it -
    THM
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    you can use a SELECT statement to list the DB's avalable for each one, individually

  3. #3
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    MS SQL Server

    use sp_databases stored procedure.

    it lists databases that reside in an instance of MS SQL Server. sp_databases returns the databases listed in the sysdatabases system table.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    97

    Sakpal and dglienna

    I am well aware of SP_Helpdb stored procedure and "SELECT * FROM tab" .
    It's not the problem of listing the databases per se. It's the problem of listing the Database Servers or their instances.
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Dont quote anyone if you can help it -
    THM
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879
    ummm, I was looking at some API that might help and I ran across EnumServicesStatus which may come in handy. Do some research on it and it might be helpful. Another theoretical idea is to employ a parasitic method where you either learn how ODBC functions, or you use it to do the work for you.
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    VB Code:
    1. 'Add a reference to MS SQL DMO Object Library
    2. Dim i As Integer
    3. Dim oNames As SQLDMO.NameList
    4. Dim oSQLApp As SQLDMO.Application
    5.  
    6. Set oSQLApp = New SQLDMO.Application
    7.    
    8. Set oNames = oSQLApp.ListAvailableSQLServers()
    9. List1.Clear
    10. For i = 1 To oNames.Count
    11.     List1.AddItem oNames.Item(i)
    12. Next
    VB/Outlook Guru!

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    he wants to see if a specific db server is already running on the machine. Oracle or SQL.
    that does SQL

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sakpal and dglienna

    Originally posted by tvssarma
    ...It's the problem of listing the Database Servers or their instances.
    My code will solve half the problem, finding all SQL servers on the
    network. All thats left is to find all Oracle servers on the network.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    97

    Re: Re: Sakpal and dglienna

    Originally posted by RobDog888
    My code will solve half the problem, finding all SQL servers on the
    network. All thats left is to find all Oracle servers on the network.
    Hi Robdog888,
    Does it work on WinME ? Because When I tried the code, it did not list the SQL server instance running on my system.(SQL Server 7.0). I have MDAC 2.7 installed. does it work with this?
    where do I get documentation for SQL DMO. because what I got was for C/C++
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Dont quote anyone if you can help it -
    THM
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

  10. #10
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263
    From the MS Books Online

    ListAvailableSQLServers Method
    The ListAvailableSQLServers method returns a NameList object that enumerates network-visible instances of Microsoft® SQL Server™ 2000.

    Applies ToApplication Object


    Syntax
    object.ListAvailableSQLServers( ) as NameList

    Parts
    object

    Expression that evaluates to an object in the Applies To list

    Prototype (C/C++)
    HRESULT ListAvailableSQLServers(
    LPSQLDMONAMELIST* ppServerNames);

    Returns
    A NameList object that enumerates instances of SQL Server.

    Remarks
    Nondefault instances of SQL Server are displayed in the form of SERVERNAME/INSTANCENAME.

    The ListAvailableSQLServers method is supported only for servers and workstations running Microsoft Windows NT® 4.0 and Microsoft Windows 2000.



    Note ListAvailableSQLServers maps to the ODBC SQLBrowseConnect function, which does not support connection pooling. Therefore, an application that enables connection pooling might encounter the error "Microsoft SQL-DMO (0x800A000E) [SQL-DMO]Not enough storage is available to complete this operation." when calling ListAvailableSQLServers.
    ListAvailableSQLServers maps to the ODBC function SQLBrowseConnect.

    If you don't have MS Books On-line, try searching the MSDN site for information on either of these.

    I would imagine that ODBC has a way to find ORACLE servers as well.

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you install the SQL Client Tools on your development system,
    you will then have the MS SQL DMO Object Library in you list for
    adding references to your vb project. When you create your
    package it will pickup the dependancies for SQLDMO also.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    97

    I have got everything

    I have SQL-DMO installed and added reference etc. I checked the documentation. but the problem is when I tested it on my WInME machine with SQLserver 7.0, it did not return the name of the server.
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Dont quote anyone if you can help it -
    THM
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

  13. #13
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: I have got everything

    Originally posted by tvssarma
    I have SQL-DMO installed and added reference etc. I checked the documentation. but the problem is when I tested it on my WInME machine with SQLserver 7.0, it did not return the name of the server.
    From my post above (directly cut/paste put of the MS BOL)...

    The ListAvailableSQLServers method is supported only for servers and workstations running Microsoft Windows NT® 4.0 and Microsoft Windows 2000.

  14. #14
    Addicted Member
    Join Date
    Jan 2001
    Location
    MPLS
    Posts
    187
    For Oracle, you'll probably just have to parse the users TNSNAMES.ORA file. That's all TOAD does to display its list of databases to connect to.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    97

    Re: Re: I have got everything

    Originally posted by szlamany
    From my post above (directly cut/paste put of the MS BOL)...
    You are absolutely correct. It was an oversight. I apologize
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Dont quote anyone if you can help it -
    THM
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

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