Link to home
Start Free TrialLog in
Avatar of robespierre_2010
robespierre_2010

asked on

ASP.NET CONNECT TO SQL SERVER DB

Hi,

I want to use a local SQL Server Db installed on my PC with an ASP.NET website that I will host with a hosting provider.

I know how to connect to the DB from my ASP.net code while I develop with Visual Studio on my PC (I have the name of the server) but I do not know what the name of my SQL Server will be once I want to access it from my code installed on the hosting provider. I guess that it is a matter of substituting the PC name with an IP address, but I do not know what that IP is or where to obtain it from.

Any help will be most welcome.

Thanks a lot in advance and regards.
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Place your connection string, or parts of it like dbserver, in the web.config.  Then you can tweak the settings at will without a recompile.

http://weblogs.asp.net/owscott/archive/2005/08/26/Using-connection-strings-from-web.config-in-ASP.NET-v2.0.aspx
Avatar of robespierre_2010

ASKER

Hi,

Thanks for the fast response. The question, though had more to do with finding out what the connection string would be rather thatn with where to put the connection string. I mean, how to find out the IP of my DB.

Regards.
run

ipconfig /all

on command line... for localhost you can use 127.0.0.1
Sorry for that.

The DBA of the hosting provider should be able to provide you with the connect information once you get ready to host the app.

I'm not aware of anyway to legitimately walk a network 'looking' for databases hoping it finds the correct one if that is what you are asking.

Maybe another Expert will know of a way.
>>ipconfig /all

That will tell you the ip address of the local machine.  I believe the question is how to find an 'unknown' remote database server.
You should be able to replace the server name value in the connection string with the ip address of your local machine which can be determined by using ipconfig /all
select @@servername
-->
MACHINENAME\SQLSERVER

once you know the name, use ping

ping MACHINENAME

to find the ip of server... but why do you need ip? name should be ok...
jacko72,
ipconfig/all has already been suggested 12 minutes ago?
@slightwv : Yes but you didn't then advise what to do with it, maybe you should spend more time reading the question and understanding it before posting answers that don't address the problem.
>>Yes but you didn't then advise what to do with it

I didn't post it.  I actually commented that in this question it wouldn't work since it was an unknown remote database not local.
The question says : I want to use a local SQL Server Db installed on my PC, don't know where you are getting that is a unknown remote database. It is remote it terms that it is going to be remote from the hosted application but it is hardly unknown.
"but I do not know what the name of my SQL Server will be once I want to access it from my code installed on the hosting provider"
Do you not think that statement should be interpreted as the SQL Server name will not be understood/resolved by the Hosting provider, why would he not know the name of his own sql server installed on his own PC. He needs to replace the name of the sql server with the IP address and instance name in the connection string e.g.
Server="192.168.1.1\myInstanceName"
I took it to mean the app AND sql server database will be hosted.

I think we need to wait for robespierre_2010 to respond to clarify any outstanding issues.
Hi,

I tried using "ipconfig /all" but that does not give me the IP address, it only gives me the IPv4 which is 192.168.1.34 and that cannot be used to connect from the remote server, as fas as I know.

I went to www.whatismyip.com and I obtained an IP. But when I try to connect to my database from Sql Server Management Studio using "IP\INSTANCENAME" i still cannot connect.

Thanks again and regards.
Please clarify:

You will keep your SQL Server database local and Host a developed app that needs to point back into your local DB Server?
slightwv:You will keep your SQL Server database local and Host a developed app that needs to point back into your local DB Server?

Correct.
you need a static ip, or dynamic dns name
get it from dyndns, something like

robesql.dyndns.info

so you can use this to connect to your sql... you need to setup your router and open sql port and route all incoming traffic to this machine
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial