1

I can connect and retrieve data from a localhost database. My app retrieves the data from a hosted sql server using the following connection string

<add name="conn" connectionString="Data Source=xxx.xxx.xx;Initial  
     Catalog=xxxx;Persist Security Info=True;User ID=xxxx;Password=xxxx"     
     providerName="System.Data.SqlClient"/>

Is there anyway I can connect to this database without uploading it to the third party service?

Johnathon Sullinger
  • 7,097
  • 5
  • 37
  • 102
ivan
  • 1,177
  • 8
  • 23
  • You would have to open port 1433 on your firewall, and map that port to your server. Think about the security on that. – Chuck Jun 29 '15 at 23:45
  • "Is there anyway I can connect to this database without uploading it to the third party service?" Do you mean without uploading the database to the hosted SQL Server? Is your problem that you don't want to upload it or that you can't connect to it. Please post the error message. – Nick.Mc Jun 30 '15 at 00:47
  • `SqlException (0x80131904):A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server` thats my error and btw @chuck so you are telling me to open the port in the place where my sql is located? and so my connection would get access? if so i'll try it tomorrow when i have access to my job's pc, and sorry for my english – ivan Jun 30 '15 at 02:18
  • Hi Ivan, Yes, if you want the database in a different LAN, you will have to make sure that you can get to it, you first can test to see it you can connect to it with a copy of SQL server management studio. Make sure you can get to it first with that, and then check your program afterwards. – Chuck Jun 30 '15 at 15:30
  • 1
    okay @Chuck i'll be trying to get that, i'll let you know what happens, thank s for your help – ivan Jun 30 '15 at 19:07
  • @Chuck just one more question should i specify the port in my connection string like this? `''` – ivan Jun 30 '15 at 20:10
  • The port number has a : (colon) before it, not the comma. Like sqlserver.stackoverflow.com:1433 – Chuck Jun 30 '15 at 20:48
  • I'm pretty sure its a comma [sql connection via ip](http://www.connectionstrings.com/sqlconnection/connect-via-an-ip-address/), but even if i add the IP and the port it keeps giving me an error, a different one tho `An attempt was made to access a socket in a way forbidden by its access permissions` should i change the port that im using for my app? – ivan Jun 30 '15 at 21:27
  • Sorry, its a comma. http://stackoverflow.com/questions/89576/how-do-you-specify-a-different-port-number-in-sql-management-studio for Studio – Chuck Jun 30 '15 at 22:22
  • 1
    @Chuck ah, i finally got it to work (i used the 1 hour trial azure web thingy) it looks like it was the hosting that didn't work properly, still why? i cant get it to work in another hosting service that is not azure. – ivan Jun 30 '15 at 22:58
  • I can directly access my SQL servers hosted in GoDaddy, maybe your hosting service can help, at least you should know if the port is open or they are using an alternate port number. It's great to know that it is not your app! – Chuck Jun 30 '15 at 23:04
  • 1
    @Chuck thanks for your help overall on this! i dont know if i can select you as a valid answer since i just made this account but if i can feel free to copy any of your comments as an answer and ill vote for it :D – ivan Jul 01 '15 at 02:05

1 Answers1

1

Test your Hosting provider by using SQL Management studio, in studio; use the full host name and a comma for the alternate port number. The default port number is 1433 for SQL Server.

After getting the connection working in studio, configure your connection string within your program.

Chuck
  • 1,001
  • 1
  • 13
  • 19