Hello!

I have a remote database that will be accessed through a client program.
The thing is, I want the client to auto detect the IP Address of the machine
where the database is located, so that when I initialize the value of my
connection string it would be like this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\AutoDetectedIpAddress\folder\myDatabase.mdb;User Id=admin;Password=;

In that way, the client program will automatically connect to the
remote database whatever the IP Address of the machine where the
remote database is. I don't have any clue to do this so, I'm
asking for your help guys.

Thanks in advance!

I suggest you reconsider connecting via the IP address. Let the infrastructure take care of name/address translation for you and just connect using the server name. Using the IP address could impact database access in a system where clustering/mirroring provides high availability.

commented: Thanks for the tip! +1

Thanks for the reply!

Ok. I'll take your advice. But is there any chance that I can do some kind of auto detect feature? If there is none, then I'd be fine with manually doing the connection.

If this is over LAN or WAN (VPN or leased line), then you can just use the computername. Your DNS or WINS will take care of the name resolution to the IP.

If you plan to connect over the internet then perhaps you've got to search services like dynDNS or something similar (google for free dynamic dns).
Some DSL routers support dynamic dns and you can have a hostname with a dynamic IP with no software.
BUT, be warned the type of access you are looking for in your "server" machine (sharing your actual file) shouldn't be done over the internet without a VPN (and because of this you don't need dynDNS).

commented: Thanks for the tip! +1

Thank you guys for your explanations!

I'll follow what you've suggested.

when i write this command ?

do you have any program that is detect the ip of my vitiam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.