[Mono-list] MSSQL from Linux using Mono - Error

Daniel Waterbly dwaterbly at msn.com
Fri Jun 24 04:24:10 EDT 2005


    I have been trying all day and night to connect to a MS SQL Server
database from my redhat linux box.  I can connect just fine to a MySQL
database, but it just won't fly with a MSSQL database.  Here is the code I
am using:

using System;
using System.Data;
using System.Data.SqlClient;

 public class sql
    public static void Main(string[] args)
                string connectionString = 
                string commandString = "select * from SUBSCRIBERS";
                SqlDataAdapter dataAdapter = new
                SqlDataAdapter(commandString, connectionString);
                DataSet dataSet = new DataSet();
                dataAdapter.Fill(dataSet, "SUB");

                int i;

                for (i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                        System.Console.WriteLine("ROW: " +
                            dataSet.Tables[0].Rows[i]["house_number"] + " " 

Everything compiles fine and it runs just grand from my Windows XP box, but
when I try mono sql.exe I get this:

Unhandled Exception: System.Net.Sockets.SocketException: Invalid arguments
in <0x00208> System.Net.Sockets.Socket:Connect (System.Net.EndPoint
in <0x0014c> Mono.Data.Tds.Protocol.TdsComm:.ctor (System.String dataSource,
Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion)
in <0x000f0> Mono.Data.Tds.Protocol.Tds:.ctor (System.String dataSource,
Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion)
in <0x00018> Mono.Data.Tds.Protocol.Tds70:.ctor (System.String server, Int32
port, Int32 packetSize, Int32 timeout)
in (wrapper remoting-invoke-with-check) Mono.Data.Tds.Protocol.Tds70:.ctor
in <0x000ae>
(Mono.Data.Tds.Protocol.TdsConnectionInfo info)
in <0x0001d> Mono.Data.Tds.Protocol.TdsConnectionPool:CreateConnection ()
in <0x0020c> Mono.Data.Tds.Protocol.TdsConnectionPool:GetConnection ()
in <0x00200> System.Data.SqlClient.SqlConnection:Open ()
in <0x0007b> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet
dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable,
IDbCommand command, CommandBehavior behavior)
in <0x00036> System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet
dataSet, System.String srcTable)
in (wrapper remoting-invoke-with-check)
System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet,string)
in <0x00080> sql:Main (System.String[] args)

Can you please help me out here? It's driving me nutty!

Dan Waterbly 

More information about the Mono-list mailing list