Showing posts with label sqlexpress. Show all posts
Showing posts with label sqlexpress. Show all posts

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!

Wednesday, March 7, 2012

Going from osql to sqlcmd (MSDE to SqlExpress?)

I am familiar with loading a DB so that it will work under MSDE. This
is the command I use:
osql -S ServerName\InstanceName -E -i ScriptName.sql
So now I uninstalled MSDE and am using SqlExpress instead. To do the
same I tried:
Sqlcmd -S .\SQLExpress -i ScriptName.sql
and
Sqlcmd -S ServerName\SQLExpress -E -i ScriptName.sql
Which does not do anything except give me an erro stating that my DB
does not exist under SQLExpress. (Which is why I was trying to
install it )
Am I missing something? Do I need MSDE running on my toolbar?
How do I load a DB into SQLExpress?
Regards
oracle wrote:
> I am familiar with loading a DB so that it will work under MSDE. This
> is the command I use:
> osql -S ServerName\InstanceName -E -i ScriptName.sql
> So now I uninstalled MSDE and am using SqlExpress instead. To do the
> same I tried:
> Sqlcmd -S .\SQLExpress -i ScriptName.sql
> and
> Sqlcmd -S ServerName\SQLExpress -E -i ScriptName.sql
>
Those commands do not load a database. They connect to the specified SQL
Server instance. The SQL service is already running and the databases
are mounted and ready. It sounds like the problem you are having is that
SQL Express does not know about your MSDE databases. How did you move
the databases to SQL Express? If you didn't move them, you might be able
to use the "CREATE DATABASE database_name FOR ATTACH" command. If you
still have MSDE installed, first detach the databases using sp_detach_db
and copy them over the SQL Express data folder. I do not know if you can
do this from SQL Express Manager.
David Gugick
Quest Software
www.quest.com