Monday, March 19, 2012

got a problem when try to connect to a sqlexpress database with c# desktop application,t hx a lo

hi experts,

I have sqlexpress installed, I can connect to it with my c# desktop application, connection string is:
"server= 192.168.0.3.\SQLEXPRESS,1921; user id='sa'; password='*****'; Database='EvoHealthSQLex'; Integrated Security=True"

as you can see 192.168.0.3 is that machine's (with sqlexpress installed) local Ip address, however I need to set it to be assessible through the Internet, so I set the port forwarding service in my router, so it's actually Ip address should be: 62.31.81.210 and I think it is working, as I can view the default website on that machine by typing in http://62.31.81.210/ in IE.

however, when I try to change the connectionstring of my c# app to :
"server= 62.31.81.210.\SQLEXPRESS,1921; user id='sa'; password='*****'; Database='EvoHealthSQLex'; Integrated Security=True"
then it's not working, whether I put the port number 1921 or not, it still working with that local Ip address 192.168.0.3 though

I wonder what is the correct way to make it accessible through Internet and what is the connection string gonna be?

Many thanks for reading my question!

ps: I saw below is a sqlexpress forum, but no post at all ?!

rayBristol,

This is a interesting scenario. "Port forwarding" should be transperant to sql connection. I guess you already made the port 1921 forwardable on your router.

To troubleshoot the connectivity,

1. Make sure the firewall is opened for port 1921 on hosting machine of the SQL Server.

2. Try "telnet 62.31.81.210 httpport (normally 80 or 8080)", and compare the result with "telnet 62.31.81.210 1921". If you can't connect for the later case, your configuration of port forward has issue. After connect, you can "ctrl+']' and quit for exit telnet.

3. Once you pass 2, if you still have troulbe connecting, you can post the errormsg and complete stack trace of your c# application when connection failes.

|||

HI, sorry I forgot to make port 1921 forwardable !

And now I did, and it works now!!!

but why you saying "Port forwarding" should be transperant to sql connection ? is that mean port forwarding has nothing to do with sql connection ?

Thanks very much for you help!!!

|||

Q:

"is that mean port forwarding has nothing to do with sql connection ?

A:

Yes, except the port needs to be configured correctly.

|||

Hi, thanks so much for you help, now I can use either local Ip address or the router ip address for the connectionstring, however, I got another problem, sounds simple, I use another computer (within the same local network) run the same program, got a login failed error, after some googling, I added a user to that database with permission to connect, but same thing happened, I wonder if you can have a look if not too much trouble:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=288311&SiteID=1&mode=1

it looks pretty long as I put lots other detials try to make this question as clear as possible.

Many thanks again for your help!

No comments:

Post a Comment