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.
robespierre_2010Asked:
Who is Participating?
 
HainKurtSr. System AnalystCommented:
router : incoming port = 1433 --> 192.168.1.34
and assign static ip to your machine, check your router configuration to do this (assign this ip to this mac address)

after this config, when you try to connect to robesql.dyndns.info, it will go to your sql server...
0
 
slightwv (䄆 Netminder) Commented:
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
0
 
robespierre_2010Author Commented:
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.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
HainKurtSr. System AnalystCommented:
run

ipconfig /all

on command line... for localhost you can use 127.0.0.1
0
 
slightwv (䄆 Netminder) Commented:
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.
0
 
slightwv (䄆 Netminder) Commented:
>>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.
0
 
Paul JacksonSoftware EngineerCommented:
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
0
 
HainKurtSr. System AnalystCommented:
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...
0
 
slightwv (䄆 Netminder) Commented:
jacko72,
ipconfig/all has already been suggested 12 minutes ago?
0
 
Paul JacksonSoftware EngineerCommented:
@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.
0
 
slightwv (䄆 Netminder) Commented:
>>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.
0
 
Paul JacksonSoftware EngineerCommented:
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.
0
 
slightwv (䄆 Netminder) Commented:
"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"
0
 
Paul JacksonSoftware EngineerCommented:
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"
0
 
slightwv (䄆 Netminder) Commented:
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.
0
 
robespierre_2010Author Commented:
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.
0
 
slightwv (䄆 Netminder) Commented:
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?
0
 
robespierre_2010Author Commented:
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.
0
 
HainKurtSr. System AnalystCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.