Monday, March 19, 2012

another simple question, please help, thx a lot!

I have some issues for remotely connection a sqlexpress server 2005 with a c# desktop app,

in my local network, after I set a port forwarding service for the computer which runs sqlexpress server, I want my c# app connect to the sqlexpress server in another machine under same local network, the connection string is:

"server= 62.31.81.210.\SQLEXPRESS,1921; Database='EvoHealthSQLex'; Integrated Security=True"

however, that one only work in the sqlexpress server machine, if I try to use it in another machine, i got error 'Login failed for user 'BRISTOL-1\Guest', BRISTOL-1 is the full computer name of sqlexpress server machine, I found out the solution is to create a login for 'BRISTOL-1\Guest' (in sever management studio express):

CREATE LOGIN [BRISTOL-1\Guest] FROM WINDOWS; GO

then it fixed the problem I mentioned above, However, what I want to ask is when I change the server authentication from 'windows authentication mode' to 'Sql server and windows authtication mode', then i try to create a user like this:

CREATE LOGIN Ross WITH PASSWORD = 'changeme'; USE EvoHealthSQLex; CREATE USER Ross; GO 
Then I change my connection string to:
"server= 62.31.81.210.\SQLEXPRESS,1921; user id='Ross'; password='changeme'; Database='EvoHealthSQLex';
then I got the following error even when I user 'sa' user:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
 
I wonder why this happening ? it should be a stupid connectionstring problem just I don't know ..
I wonder can I use 'windows authentication' for remote access (outside local network)? if so, how do i specified the username, all BRISTOL-1\Guest ?
 
thanks a lot for your reading!
Can you post the extire exception stack trace?|||

sorry, it was a syntax program, I was being silly again...

it should be:

"server= 62.31.81.210.\SQLEXPRESS,1921; user id='Ross'; password='changeme'; Database='EvoHealthSQLex' "

I put a extra ';' in the end of the statement :

"server= 62.31.81.210.\SQLEXPRESS,1921; user id='Ross'; password='changeme'; Database='EvoHealthSQLex' ; "

now above error message disappear!

thanks very much for your help, learn a lot for this forum, as a newbie :)

|||

Hi, got a last question of this remote connection problem:

I send my program to my friend and ask him run it (as all my computer is within the same local network, although I use the router Ip address 62.31.81.210 instead of local ip address 168.192.0.3) and he got a error say' SQL server is not exist or access denied', I wonder whatelse can cause that happen ? anything to do with the port forwarding service? he does can browse my test website hosting in the same machine using the same ip address http://62.31.81.210(I also do a port forwarding service with port 80 as well), I wonder why he failed to connect to sqlexpress server...

Many thanks!

|||

You can find lots of troubleshooting info through

http://blogs.msdn.com/sql_protocols/archive/2005/10/22/483684.aspx

In your case, the errormsg indicates that the client do not have connecitivity to the server. "168.192.0.3" mean host local address, which normally mean the host does not haveconnecitvity to the network. I am surprised that with 168.192.0.3, you can browse the server.

One you made sure you have network connectivity, you can try to "telnet 62.31,81,210 port" to see if TCP connectivity is ok between your client host and remote server. "use ctrl +]" and "quit" to exit the telnet console.

Once you have telnet test passes, you may try your sql connection.

|||

hi, thanks for your reply again, I just ask my another friend to try it and it works! I didn't use the local Ip address '168.192.0.3', I use the '62.31,81,219 1921', and I connect it with tcp/ip with no problem, so probably is my first friend's computer problem.

so far so good, thanks so much for your help, really appreciated !

No comments:

Post a Comment