|
-
Sep 20th, 2002, 08:38 AM
#1
Thread Starter
Fanatic Member
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
-
Sep 20th, 2002, 08:47 AM
#2
Addicted Member
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
-
Sep 20th, 2002, 08:50 AM
#3
Thread Starter
Fanatic Member
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...
-
Sep 20th, 2002, 08:59 AM
#4
Addicted Member
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
-
Sep 24th, 2002, 10:04 AM
#5
Thread Starter
Fanatic Member
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
-
Sep 24th, 2002, 10:24 AM
#6
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.
-
Sep 24th, 2002, 10:28 AM
#7
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.
-
Sep 24th, 2002, 10:41 AM
#8
Let me in ..
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
-
Sep 30th, 2002, 02:19 PM
#9
Thread Starter
Fanatic Member
thanks a lot techyspecy... that was great.. i think that should help me
-
May 8th, 2005, 09:51 PM
#10
Hyperactive Member
Re: dynamic server connection
thechgnome..what do u mean by use offensive programming,not defensive programming?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|