From 0fb926e9ed6b8cabf857866ceb146721362b535a Mon Sep 17 00:00:00 2001 From: Daniel Morgan Date: Sun, 16 Feb 2003 15:11:40 +0000 Subject: 2003-02-16 Daniel Morgan * SybaseConnection.cs: - parse data source for 2 possible uses: "Server=hostname", "Server=hostname,port" and open the connection based on the resulting server name and port. svn path=/trunk/mcs/; revision=11625 --- mcs/class/Mono.Data.SybaseClient/ChangeLog | 7 +++++ .../Mono.Data.SybaseClient/SybaseConnection.cs | 31 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'mcs/class/Mono.Data.SybaseClient') diff --git a/mcs/class/Mono.Data.SybaseClient/ChangeLog b/mcs/class/Mono.Data.SybaseClient/ChangeLog index 1d23029b063..28bd41069fd 100644 --- a/mcs/class/Mono.Data.SybaseClient/ChangeLog +++ b/mcs/class/Mono.Data.SybaseClient/ChangeLog @@ -1,3 +1,10 @@ +2003-02-16 Daniel Morgan + + * SybaseConnection.cs: - parse data source for 2 possible uses: + "Server=hostname", + "Server=hostname,port" and open the connection based on the + resulting server name and port. + 2002-12-01 Tim Coleman * Mono.Data.SybaseClient/SybaseDataReader.cs: Change to reflect TdsSchemaInfo -> TdsDataColumnCollection diff --git a/mcs/class/Mono.Data.SybaseClient/Mono.Data.SybaseClient/SybaseConnection.cs b/mcs/class/Mono.Data.SybaseClient/Mono.Data.SybaseClient/SybaseConnection.cs index 08a88e73666..dfa513d7981 100644 --- a/mcs/class/Mono.Data.SybaseClient/Mono.Data.SybaseClient/SybaseConnection.cs +++ b/mcs/class/Mono.Data.SybaseClient/Mono.Data.SybaseClient/SybaseConnection.cs @@ -3,8 +3,10 @@ // // Author: // Tim Coleman (tim@timcoleman.com) +// Daniel Morgan (danmorg@sc.rr.com) // -// Copyright (C) Tim Coleman, 2002 +// Copyright (C) Tim Coleman, 2002, 2003 +// Copyright (C) Daniel Morgan, 2003 // using Mono.Data.Tds.Protocol; @@ -16,6 +18,7 @@ using System.Data; using System.Data.Common; using System.EnterpriseServices; using System.Net; +using System.Net.Sockets; using System.Text; namespace Mono.Data.SybaseClient { @@ -282,16 +285,20 @@ namespace Mono.Data.SybaseClient { [MonoTODO ("Figure out the Sybase way to reset the connection.")] public void Open () { + string serverName = ""; if (connectionString == null) throw new InvalidOperationException ("Connection string has not been initialized."); try { - if (!pooling) - tds = new Tds50 (DataSource, port, PacketSize, ConnectionTimeout); + if (!pooling) { + ParseDataSource (dataSource, out port, out serverName); + tds = new Tds50 (serverName, port, PacketSize, ConnectionTimeout); + } else { pool = (SybaseConnectionPool) SybaseConnectionPools [connectionString]; if (pool == null) { - pool = new SybaseConnectionPool (dataSource, port, packetSize, ConnectionTimeout, minPoolSize, maxPoolSize); + ParseDataSource (dataSource, out port, out serverName); + pool = new SybaseConnectionPool (serverName, port, packetSize, ConnectionTimeout, minPoolSize, maxPoolSize); SybaseConnectionPools [connectionString] = pool; } tds = pool.AllocateConnection (); @@ -315,6 +322,22 @@ namespace Mono.Data.SybaseClient { } } + private void ParseDataSource (string theDataSource, out int thePort, out string theServerName) + { + theServerName = ""; + thePort = 1433; // default TCP port for SQL Server + + int idx = 0; + if ((idx = theDataSource.IndexOf (",")) > -1) { + theServerName = theDataSource.Substring (0, idx); + string p = theDataSource.Substring (idx + 1); + thePort = Int32.Parse (p); + } + else { + theServerName = theDataSource; + } + } + void SetConnectionString (string connectionString) { connectionString += ";"; -- cgit v1.2.3