November 30, 2005 at 4:09 pm
Hey.
I'm new to SQL server. Can someone explain to me how I connect to the SQL server that is on my computer, from a web page? I have created an ASP page and uploaded it onto a web server, but I need to be able to read from my database that is on SQL server on my computer? how do I do this?
December 1, 2005 at 4:27 am
In ASP.NET, you can try this code:
string MyConnectionString =
string.Format("Provider=SQLOLEDB; Data Source={0}; " +
" Initial Catalog={1};User ID={2}; Password={3}",
URL, DBName, UserID, Password);
OleDbConnection _connection = new OleDbConnection(MyConnectionString);
_connection.Open();
string sql = "SELECT TOP 1 * FROM MyTable";
OleDbDataAdapter da = new OleDbDataAdapter(sql, _connection);
DataSet ds = new DataSet();
da.Fill(ds);
December 1, 2005 at 11:27 am
Ok, but what do I use for values? like, what do I use for data source, or what is the url to my computer? do I use my IP address anywhere? please explain how this works. If I'm connection from a website to my computer, my computer would have to be on so that the website can access it, right? Or does the ASP page always need to be on the same server as the SQL server?
December 1, 2005 at 11:36 am
The datasource is the name of the database (such as Northwind)
The URL is the IP address of the server (or 127.0.0.1 if the web server is on the same machine as the database)
Many times the database is placed on its own server, and therefore you would have to use the real IP address of the server the database is on.
December 1, 2005 at 12:45 pm
how do I find out what my IP address is? when I type in IPCONFIG in dos, all it gives me is the IP address of my network, which is the generic 192.168.0.101. How do I find the one that I can actually use to connect to my computer?
December 1, 2005 at 2:29 pm
I don't know the answer. If you install the client tools (Query Analyzer, etc..) on another computer, and try connecting using the various IP addresses it should be easy enough to figure it out.
Rick
December 2, 2005 at 11:41 am
December 6, 2005 at 5:58 am
try visiting http://www.whatismyip.com
That will tell you your external IP address, but this is only the address of your router, not necessarily YOUR ip.
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply