Bob Schneider
asked on
Recognize PC Name in VB6
I have an app that was written in vb6 years ago. I use the app on several different machines and I am wondering if there is a way that I can get it to recognize the name of the pc so I can access the sql server 2008 database regardless of which machine I am running it on (ie: "\PCName\SQLExpress". Or better yet, get at the local db without making a machine reference at all.
Thanks~
Thanks~
Can you just put the SQL DB on a network drive and have everyone access the same database?
ASKER
We use the software in remote locations that are not on a network. I will look at the previous solution. It looks like it might work. The only way to do something like "App.Path" would be to put the db in the same directory as the compiled application, right?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great! Thanks!!
'Add the below API call to the general declarations section of any code module
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'Then add this to call the API function. Modify the naming convention to suit your needs.
Dim str_computer_name As String, lng_buffer_size As Long, lng_ret_code As Long, lng_null_character_positio
str_computer_name = Space(80)
lng_buffer_size = Len(str_computer_name)
lng_ret_code = GetComputerName(str_comput
lng_null_character_positio
If lng_null_character_positio
str_computer_name = Left(str_computer_name, lng_null_character_positio
Else
str_computer_name = " "
End If