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

muppetboy simon.harding at iname.com
Mon May 22 11:33:32 EDT 2006


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.




More information about the Mono-devel-list mailing list