[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Get Unique PC Identifier

Posted on 2013-05-25
11
Medium Priority
?
799 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

649 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