?
Solved

Get Unique PC Identifier

Posted on 2013-05-25
11
Medium Priority
?
789 Views
Last Modified: 2013-05-26
Hi.  I have a piece of software that I run on multiple machines.  Currently you have the option of running it remotely off of the server db or off of the db on the local machine.  I currently have all of the machines that use the software listed in a dropdown so that the user can either check "Remote" or the name of their machine, and the software finds the database from the machine name.  It works fine but I would like to simplify it and allow them to simply choose "Remote" or "Local".  If they choose "local, it will find the database on the machine that they are on.  

When I am working on another machine I constantly choose my normal machine and then I have to wait until it times out because it can't find it (since that is not the machine that I am on) before I correct my mistake.  There has to be a way to "find" the database on the local machine without hard-coding the name into a dropdown???

Any help?
0
Comment
Question by:Bob Schneider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 14

Assisted Solution

by:Faustulus
Faustulus earned 332 total points
ID: 39197133
Couldn't you let the program search for the db in a certain sequence, like, IF the db is found on the local machine, use that db, else look for the db on a remote server?
If you need a method to force the program to select the db of the user's choice you might add a drop-down with the choices "Auto" and "Select" where the former is the process I have just described and the latter the one you presently have.
0
 

Author Comment

by:Bob Schneider
ID: 39197149
Good suggestion but I want to be able to choose local or remote because it is quicker to run it off of the local db than the server, but how can I get it to look for a local db?  Here is my current connection string:

    If sWhichSrvr = "Remote" Then
        conn.Open "Provider=SQLNCLI10;Server=216.185.199.1,1433\SQLExpress;Database=VIRA;Uid=uid;Pwd=pwd;"
    Else
        conn.Open "Provider=SQLNCLI10;Server=" & sWhichSrvr & "\SQLExpress;Database=dbname;Trusted_Connection=yes;"
    End If

Open in new window

0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 332 total points
ID: 39197194
If there is an Install procedure for your program, I would have it make an 'ini' file that tells whether there is supposed to be a local database server or not.  If there is not, then it should always connect to the remote.  If it is local you could store the local part of the connection string in the 'ini' file.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:Bob Schneider
ID: 39197198
Actually I just run it out of the exe for now...may change that later.  Can I conclude that there is no way to determine the machine name or some other identifier using vb6?
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 1336 total points
ID: 39197217
Can I conclude that there is no way to determine the machine name or some other identifier using vb6?
There are Windows API calls to identify the machine name.  I can look it up if you want.

Alternatively, you can reduce the connection time so that you do not have to wait 30 seconds.
0
 

Author Comment

by:Bob Schneider
ID: 39197219
I would love to know how to do a Windows API Call to identify the machine name if you would be so kind.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 1336 total points
ID: 39197267
Here is one example I found:
http://www.vb6.us/tutorials/simple-windows-api-example

There was a site I used to use around 10 years ago that had every possible Windows API call that you could possibly think of using VB6, but for the life of me the name escapes me.  If i find it I will post it.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 1336 total points
ID: 39197270
Here it is:  VBnet Visual Basic Developers Resource Centre

P.S. Don't let the VBnet name fool you, it is all Visual Basic classic.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 1336 total points
ID: 39197272
On second thoughts, you may not need to use a Windows API (although that would certainly work).  There are a couple of other options:
1. The environment variable COMPUTERNAME contains the name (this should be simple call).  This can be spoofed though.
2. You should be able to use the WScript.Network object model to get it also.
0
 

Author Comment

by:Bob Schneider
ID: 39197655
Awesome!  Thank you!!
0
 

Author Closing Comment

by:Bob Schneider
ID: 39197658
Great stuff!
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question