By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,855 Members | 1,988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,855 IT Pros & Developers. It's quick & easy.

localhost Accessing Remote SQL Database

P: n/a
Hi -

I have an ASP.NET web page accessing a SQL database. It works fine on the
web, and I'm trying to get it to also work in debug mode in the IDE. The
"on the web" page and my SQL database are hosted by a third party (on
separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.

While I've provided (below) my entire page load event code, the connection
string that works when I upload the page to the third-party host is:

Network Library=dbmssocn;Password=myPassword;User ID=myUser;Initial
Catalog=myDB;Data Source=000.000.000.000;

[values are changed for reasons of security.]

When I try to run the page on my development machine in debug mode, IE
opens, the status bar reports that it is opening my localhost page, and IE
hangs. (Eventually I get a page cannot be displayed error.) Again, this
same page works fine when uploaded.

I've also tried adding a ",1433" at the end of the Data Source URL as
suggested by connectionstrings.com. Same result.

How can I get this to work??

Thanks for your help.

- Jeff

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM Customers",
conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Jeff,

I develope locally and use an ASP.Net host to host all my sites and
databases. I've never had any trouble hitting the remote database from
inside VS.Net. For my connection string I've always used:

"SERVER=000.000.000.000; database=dbName; uid=UserName; pwd=Password;"

If using that doesn't help could you step through your code and let us know
which line it is hanging on. You may also want to use the Server Explorer
to connect to the DB just make sure it is working and hittable. Good luck!
Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:E6****************@newsread3.news.atl.earthli nk.net...
Hi -

I have an ASP.NET web page accessing a SQL database. It works fine on the
web, and I'm trying to get it to also work in debug mode in the IDE. The
"on the web" page and my SQL database are hosted by a third party (on
separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.

While I've provided (below) my entire page load event code, the connection
string that works when I upload the page to the third-party host is:

Network Library=dbmssocn;Password=myPassword;User ID=myUser;Initial
Catalog=myDB;Data Source=000.000.000.000;

[values are changed for reasons of security.]

When I try to run the page on my development machine in debug mode, IE
opens, the status bar reports that it is opening my localhost page, and IE
hangs. (Eventually I get a page cannot be displayed error.) Again, this
same page works fine when uploaded.

I've also tried adding a ",1433" at the end of the Data Source URL as
suggested by connectionstrings.com. Same result.

How can I get this to work??

Thanks for your help.

- Jeff

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM Customers",
conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub

Nov 19 '05 #2

P: n/a
Thanks Ken -

After trying various combinations, including your suggested connection
string format, I no longer believe that the problem is with the connection
string (yours had the same result as the one I had tried).

As far as I can tell now, I think the issue may be a Page directive issue:
src vs codebehind. I've posted it in a new thread, since the 'Subject' no
longer applies; it's now posted as 'Running both in the IDE and on a remote
host.' I'd appreciate any further suggestions you can offer.

- Jeff
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
Hi Jeff,

I develope locally and use an ASP.Net host to host all my sites and
databases. I've never had any trouble hitting the remote database from
inside VS.Net. For my connection string I've always used:

"SERVER=000.000.000.000; database=dbName; uid=UserName; pwd=Password;"

If using that doesn't help could you step through your code and let us know which line it is hanging on. You may also want to use the Server Explorer
to connect to the DB just make sure it is working and hittable. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:E6****************@newsread3.news.atl.earthli nk.net...
Hi -

I have an ASP.NET web page accessing a SQL database. It works fine on the web, and I'm trying to get it to also work in debug mode in the IDE. The "on the web" page and my SQL database are hosted by a third party (on
separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an always-on DSL connection, I'm hoping there's a way to get this to work.

While I've provided (below) my entire page load event code, the connection string that works when I upload the page to the third-party host is:

Network Library=dbmssocn;Password=myPassword;User ID=myUser;Initial
Catalog=myDB;Data Source=000.000.000.000;

[values are changed for reasons of security.]

When I try to run the page on my development machine in debug mode, IE
opens, the status bar reports that it is opening my localhost page, and IE hangs. (Eventually I get a page cannot be displayed error.) Again, this same page works fine when uploaded.

I've also tried adding a ",1433" at the end of the Data Source URL as
suggested by connectionstrings.com. Same result.

How can I get this to work??

Thanks for your help.

- Jeff

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM Customers", conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.