Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server on a remote machine

Author  Topic 

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 07:36:19
Hello,

I've developed an application with .NET and I would like this application to access a SQL server database which is situated on a remote machine. I've set the connectionString like this :
\\server\SQLExpress ...
but it doesn't work
Is there anything else to do ?
I guess I have to set some trust settings but I don't know how...
Could anyone help me to solve this problem ?

Thank you in advance,

mathmax

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 07:42:33
www.connectionstrings.com



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 09:24:19
Hello,

I write this connectionstring :
Server=\\server\SQLExpress;Database=myDataBase;Trusted_Connection=True;

but I get the following error :
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 09:32:09
According to the link I provided, your connection string should look something similar to
"Provider=SQLNCLI;Server=ServerMachineName\SQLExpress;Database=myDataBase;Trusted_Connection=True;"



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 10:00:00
In fact I use nhibernate to access the database. There is already a provider for nhibernate.
When I add "Provider=SQLNCLI;" in the connectionstring, it is said that provider is not a known keyword.
The connection settings for nhibernate look like this :

<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
<add key="hibernate.connection.connection_string" value="Server=\\Server\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>
</nhibernate>

but I still get the same error message :
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 10:18:03
You are still using UNC path to server. Try to remove double \ and try without them.

<add key="hibernate.connection.connection_string" value="Server=Server\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 10:30:28
Yes, I tried this but I get the same error message (error 26 instead of error 5 in the above message).
Perhaps there is some trust properties or admission to define for the database ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 10:37:39
And what exactly is "Error 26"?




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 10:54:16
error 26 : occurs when I remove "\\": invalid server location
error 5 : occurs with "\\": invalid parameter.
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 13:19:02
No idea of the problem ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 13:43:18
The Error 26 is more correct! You should not have double backslash characters.
Is the server where SQLExpress is installed named "Server"?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 16:23:52
Is the server where SQLExpress is installed named "Server"?
No it is just an example.
I've also followed the instructions of this screencast : http://www.sqlserver2005.de/Screencast/Screencast.aspx?ScreencastId=1
And I've created exceptions in Windows Firewall as axplained here :
http://support.microsoft.com/default.aspx?scid=kb;en-us;914277
but the problem still remains the same...
Is there other settings to define ?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-18 : 16:26:37
Begs the question then

What the name of the server you installed it on?

Is it a laptop/desktop?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 16:34:04
It is a laptop called rar. Why ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 16:45:57
Because the title says you are trying to connect to a REMOTE sql server installation, not local on your laptop.
Local computer can be reached with

<add key="hibernate.connection.connection_string" value="Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>

or

<add key="hibernate.connection.connection_string" value="Server=.\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>

or

<add key="hibernate.connection.connection_string" value="Server=127.0.0.1\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 17:16:27
yes all those connections string work on my laptop if I want to execute my program localy. But I want my laptop (in which the database is stored) to be the server and execute the program on a client machine. So the program have to access a remote database.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 17:19:57
Ok, do your laptop have a firewall?
SQL Server listens by default on port 1433.

Are you connected to the same net and subnet mask as the computer calling your laptop?

This could work
<add key="hibernate.connection.connection_string" value="Server=rar\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 19:09:17
As I was saying, I've created exceptions in Windows Firewall.
I also tried this connections string
<add key="hibernate.connection.connection_string" value="Server=rar\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>
but get the same error...

SQL Server listens by default on port 1433.
Are you connected to the same net and subnet mask as the computer calling your laptop?
What does that mean ?
How can I check that ?
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-09-18 : 19:19:54
what do you get when you ping the machines one from the other.
xx.xx.xx.xx is the ip of machine 2
yy.yy.yy.yy is the ip of machine 1

you can get the ip by running ipconfig /all at the dos prompt.

run from machine2
ping machine1.fullyqualifieddomainname
or
ping yy.yy.yy.yy

run from machine1
ping machine2.fullyqualifieddomainname
or
ping xx.xx.xx.xx

Have you checked out the surface area configuration for SQL 2K5.
Make sure remote connections are allowed.
http://www.developer.com/db/article.php/3496511

Are both machines on a domain?same domain? if different domain do the domains have trust?

Have you tried creating a sql server login and trying to login using a sql login instead of windows login?

Is there a firewall between the machines? Try running a traceroute to see the ip hops.
run the following at the command prompt-->> tracert ipaddress

What response do you get when you try to telnet to the machine on port 1433?
run the following at the command prompt-->> telnet ipaddress 1433






Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2007-09-18 : 22:43:34
ok, I started the sql server browser and it works. But i don't know why...
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-09-19 : 00:10:46
It communicates with sql client and provides server connection info like port number.
Go to Top of Page
    Next Page

- Advertisement -