Results 1 to 10 of 10

Thread: dynamic server connection

  1. #1

    Thread Starter
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724

    dynamic server connection

    hi

    when we write a database app. in connect object connect string we give the server name and database name...

    in my case the server name will be dynamic.. i.e. the application when delopyed at client side need to know the server name..

    i am using vb6 and sql 2k

    thanks

  2. #2
    Addicted Member chicocouk's Avatar
    Join Date
    Sep 2001
    Posts
    207
    Make the server name a variable. Ask the user for the server name and store it in an ini, or the registry the first time they run the app.
    MCSE, Mcp+I, Unicenter Engineer

  3. #3

    Thread Starter
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724
    Originally posted by chicocouk
    Make the server name a variable. Ask the user for the server name and store it in an ini, or the registry the first time they run the app.
    that a simple one... which i have currently that but i need some thing which the system get the server name...

  4. #4
    Addicted Member chicocouk's Avatar
    Join Date
    Sep 2001
    Posts
    207
    You would like the program to automatically find any sql servers on the network and create connections to them? Surely the server name isn't THAT dynamic? They don't just rename their sql servers for a giggle?

    If you want the app to search for all sql servers on the network, and ask the user to choose one, i guess that's possible, but at that point, why not just ask them to provide the name of the server?
    MCSE, Mcp+I, Unicenter Engineer

  5. #5

    Thread Starter
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724
    Originally posted by chicocouk
    You would like the program to automatically find any sql servers on the network and create connections to them? Surely the server name isn't THAT dynamic? They don't just rename their sql servers for a giggle?

    If you want the app to search for all sql servers on the network, and ask the user to choose one, i guess that's possible, but at that point, why not just ask them to provide the name of the server?
    that gr8... i dont have more than one sql server on network so nothing to worry.. the thing i app need to know is the server name and use it in connection string...

    can u post the code

    thanks

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Create a login screen. Ask for the user name, their password, and the server name.
    When they login, store the server name in the registry.
    Then, when ever you need it, it's there, plus the next time they login, you can put the server name in the text box for them automatically.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by chicocouk
    You would like the program to automatically find any sql servers on the network and create connections to them? Surely the server name isn't THAT dynamic? They don't just rename their sql servers for a giggle?

    If you want the app to search for all sql servers on the network, and ask the user to choose one, i guess that's possible, but at that point, why not just ask them to provide the name of the server?
    It's possible tha tserver names could be that dynamic, not because they get renamed, but because.... well, let me put it in the context of how it is here....
    We support several clients, not all of their DBs fit onto one server, nor do all of our depts use the same server (QA has one, Client Services has one, and the developers have their own).... so when we login using our app, we (being theuser) supply the server (which gets stored in the registry), the database name (also gets plugged into the registry), user name (pulled from the logon api) and password.
    So, if I'm doing a support issue, an I need to work in the same environ as the client, I know I need to login to Server A, but when I go to fix it, I develope on Server B.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Add a refrence to ...

    Microsoft SQLDMO object library.

    Add a combobox to your form ... combo1

    call this function on form_load or anytime.

    Private Sub FillServers()
    On Error GoTo LocalErr
    Dim ServerNameList As SQLDMO.NameList
    Dim oSQLServer2 As SQLDMO.SQLServer2
    Dim iCount As Integer

    Set oSQLServer2 = CreateObject("SQLDMO.SQLServer2")
    Set ServerNameList = oSQLServer2.Application.ListAvailableSQLServers

    For iCount = 1 To ServerNameList.Count
    cboServerName.AddItem ServerNameList.Item(iCount)
    Next

    cboServerName.ListIndex = 0

    LocalExit:
    Set ServerNameList = Nothing
    Set oSQLServer2 = Nothing
    Exit Sub
    LocalErr:
    MsgBox Err.Number & " : " & Err.Source & " : " & Err.Description, vbCritical + vbOKOnly, App.Title
    GoTo LocalExit
    End Sub



  9. #9

    Thread Starter
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724
    thanks a lot techyspecy... that was great.. i think that should help me

  10. #10
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    Re: dynamic server connection

    thechgnome..what do u mean by use offensive programming,not defensive programming?
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

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