[Mono-dev] Problems connecting to MS SQL with C# and Mono

2006-05-22 Thread muppetboy

Hi,

I've tried looking for a solution to this, but not found anything. 
Hopefully someone on this list will be able to point me in the right
direction.

I get a horrible exception when attempting to connect to an MS SQL Express
server from Mono (it works under the MS CLR).  

Here is the code I use to make the connection:

string ConnectionString = Data Source=127.0.0.1\SQLEXPRESS;
Database=mydatabase;User ID=user;Password=password;

SqlConnection DatabaseConnection = new SqlConnection(ConnectionString);
DatabaseConnection.Open(); //Exception thrown here

The exception I get is:

System.Net.Sockets.SocketException: Connection reset by peer
in 0x0008f System.Net.Sockets.Socket:ReceiveFrom_nochecks (System.Byte[]
buf,
Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)
in 0x00045 System.Net.Sockets.Socket:ReceiveFrom (System.Byte[] buf,
System.Ne
t.EndPoint remote_end)
in 0x00091 System.Net.Sockets.UdpClient:Receive (System.Net.IPEndPoint
remoteE
P)
in 0x001bc
System.Data.SqlClient.SqlConnection+SqlMonitorSocket:DiscoverTcpPor
t ()
in 0x00039
System.Data.SqlClient.SqlConnection:DiscoverTcpPortViaSqlMonitor (S
ystem.String ServerName, System.String InstanceName)
in 0x00110 System.Data.SqlClient.SqlConnection:ParseDataSource
(System.String
theDataSource, System.Int32 thePort, System.String theServerName)
in 0x00161 System.Data.SqlClient.SqlConnection:Open ()
in 0x000e7 GADatabase.GADatabaseLog2:.ctor (System.String
ServerAndInstanceNam
e, System.String UserName, System.String PassWord, System.String Database)

I've tried it on both mono 1.1.15 and 1.1.13.2.

Any ideas what I'm doing wrong? Or is this a mono issue?

cheers in advance,

Simon
--
View this message in context: 
http://www.nabble.com/Problems+connecting+to+MS+SQL+with+C-+and+Mono-t1663529.html#a4507372
Sent from the Mono - Dev forum at Nabble.com.

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Problems connecting to MS SQL with C# and Mono

2006-05-22 Thread Joe Audette

Hi,


I get a horrible exception when attempting to connect to an MS SQL Express
server from Mono (it works under the MS CLR).  

Here is the code I use to make the connection:

string ConnectionString = Data Source=127.0.0.1\SQLEXPRESS;
Database=mydatabase;User ID=user;Password=password;

SqlConnection DatabaseConnection = new SqlConnection(ConnectionString);
DatabaseConnection.Open(); //Exception thrown here


2 things jump out at me.
1. Your connection string has 127.0.0.1 which when running on the mono machine 
would point to the mono machine so unless you are running mono on windows that 
could be part of the problem.
2. Your connection string is apparently using integrated windows security since 
it has no user name and password. This probably won't work if the mono machine 
is a linux machine.

Hope it helps,

Joe




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Problems connecting to MS SQL with C# and Mono

2006-05-22 Thread muppetboy

Hi,

Cheers for the responses.  I forgot to mention that I'm testing under
Windows, although I will be deploying under Linux.  I've been compiling via
Vis Studio, and testing it under mono and the clr.  

Running with the --debug option, the exception is:
Unhandled Exception: System.Net.Sockets.SocketException: Connection reset by
pee
r
in [0x00047] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System\System.Net.S
ockets\Socket.cs:1527) System.Net.Sockets.Socket:ReceiveFrom_nochecks
(System.By
te[] buf, Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint
remot
e_end)
in [0x00054] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System\System.Net.S
ockets\Socket.cs:1446) System.Net.Sockets.Socket:ReceiveFrom (System.Byte[]
buf,
 System.Net.EndPoint remote_end)
in [0x0003c] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System\System.Net.S
ockets\UdpClient.cs:287) System.Net.Sockets.UdpClient:Receive
(System.Net.IPEndP
oint remoteEP)
in [0x000a4] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System.Data\System.
Data.SqlClient\SqlConnection.cs:958)
System.Data.SqlClient.SqlConnection+SqlMoni
torSocket:DiscoverTcpPort ()
in [0x9] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System.Data\System.
Data.SqlClient\SqlConnection.cs:627)
System.Data.SqlClient.SqlConnection:Discove
rTcpPortViaSqlMonitor (System.String ServerName, System.String InstanceName)
in [0x00089] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System.Data\System.
Data.SqlClient\SqlConnection.cs:571)
System.Data.SqlClient.SqlConnection:ParseDa
taSource (System.String theDataSource, System.Int32 thePort, System.String
theSe
rverName)
in [0x000b0] (at
C:\cygwin\tmp\scratch\mono-1.1.15\mcs\class\System.Data\System.
Data.SqlClient\SqlConnection.cs:517)
System.Data.SqlClient.SqlConnection:Open ()

in 0x000dc GADatabase.GADatabaseLog2:.ctor (System.String
ServerAndInstanceNam
e, System.String UserName, System.String PassWord, System.String Database)
in 0x00071 MessagePassingTest2.Program:test (System.String whichOne)
in 0x000b2 MessagePassingTest2.Program:Main (System.String[] args)

Hope this makes more sense!

Thanks again,

Simon
--
View this message in context: 
http://www.nabble.com/Problems+connecting+to+MS+SQL+with+C-+and+Mono-t1663529.html#a4508930
Sent from the Mono - Dev forum at Nabble.com.

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Problems connecting to MS SQL with C# and Mono

2006-05-22 Thread Daniel Morgan

If you know the TCP port, use it in your connection string.

Do you have the ability to connect to SQL Server using TCP/IP. By default, SQL Server 2005 Express has this turned off --- which is good from a security standpoint.

See my two backslashes below.

string ConnectionString = "Data Source=127.0.0.1\\SQLEXPRESS;Database=mydatabase;User ID=user;Password=password";
Here, I am using TCP port to connect.

string ConnectionString = "Data Source=127.0.0.1,1433;Database=mydatabase;User ID=user;Password=password";
See http://www.mono-project.com/SQLClientfor more info.

If 127.0.0.1 does not work, try localhost. Or actually try your machine name.
Or you firewall could be blocking the port.
- Original Message From: muppetboy [EMAIL PROTECTED]To: mono-devel-list@lists.ximian.comSent: Monday, May 22, 2006 11:33:32 AMSubject: [Mono-dev] Problems connecting to MS SQL with C# and Mono
Hi,I've tried looking for a solution to this, but not found anything. Hopefully someone on this list will be able to point me in the rightdirection.I get a horrible exception when attempting to connect to an MS SQL Expressserver from Mono (it works under the MS CLR).Here is the code I use to make the connection:string ConnectionString = "Data Source=127.0.0.1\SQLEXPRESS;Database=mydatabase;User ID=user;Password=password";SqlConnection DatabaseConnection = new SqlConnection(ConnectionString);DatabaseConnection.Open(); //Exception thrown hereThe exception I get is:System.Net.Sockets.SocketException: Connection reset by peerin 0x0008f System.Net.Sockets.Socket:ReceiveFrom_nochecks (System.Byte[]buf,Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)in 0x00045 System.Net.Sockets.Socket:ReceiveFrom (System.Byte[]
 buf,System.Net.EndPoint remote_end)in 0x00091 System.Net.Sockets.UdpClient:Receive (System.Net.IPEndPointremoteEP)in 0x001bcSystem.Data.SqlClient.SqlConnection+SqlMonitorSocket:DiscoverTcpPort ()in 0x00039System.Data.SqlClient.SqlConnection:DiscoverTcpPortViaSqlMonitor (System.String ServerName, System.String InstanceName)in 0x00110 System.Data.SqlClient.SqlConnection:ParseDataSource(System.StringtheDataSource, System.Int32 thePort, System.String theServerName)in 0x00161 System.Data.SqlClient.SqlConnection:Open ()in 0x000e7 GADatabase.GADatabaseLog2:.ctor (System.StringServerAndInstanceName, System.String UserName, System.String PassWord, System.String Database)I've tried it on both mono 1.1.15 and 1.1.13.2.Any ideas what I'm doing wrong? Or is this a mono issue?cheers in advance,Simon--View this message in context:
 http://www.nabble.com/Problems+connecting+to+MS+SQL+with+C-+and+Mono-t1663529.html#a4507372Sent from the Mono - Dev forum at Nabble.com.___Mono-devel-list mailing listMono-devel-list@lists.ximian.comhttp://lists.ximian.com/mailman/listinfo/mono-devel-list___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list