localhost Accessing Remote SQL Database

J

Jeff

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
 
K

Ken Dopierala Jr.

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.
 
J

Jeff

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. said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top