//
-// Mono.Data.TdsClient.Internal.Tds42.cs
+// Mono.Data.Tds.Protocol.Tds42.cs
//
// Author:
// Tim Coleman (tim@timcoleman.com)
// Copyright (C) 2002 Tim Coleman
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
-using System.Data.Common;
-namespace Mono.Data.TdsClient.Internal {
- internal class Tds42 : Tds, ITds
+namespace Mono.Data.Tds.Protocol {
+ public class Tds42 : Tds
{
#region Fields
#region Constructors
public Tds42 (string server, int port)
- : this (server, port, 512)
+ : this (server, port, 512, 15)
{
}
- public Tds42 (string server, int port, int packetSize)
- : base (server, port, packetSize, Version)
+ public Tds42 (string server, int port, int packetSize, int timeout)
+ : base (server, port, packetSize, timeout, Version)
{
}
byte pad = (byte) 0;
byte[] empty = new byte[0];
- bool isOkay = true;
Comm.StartPacket (TdsPacketType.Logon);
Comm.SendPacket ();
- TdsPacketResult result;
-
- while (!((result = ProcessSubPacket()) is TdsPacketEndTokenResult)) {
- if (result is TdsPacketErrorResult) {
- isOkay = false;
- break;
- }
- // XXX Should really process some more types of packets.
- }
+ MoreResults = true;
+ SkipToEnd ();
- // XXX Possible bug. What happend if this is cancelled before the logon
- // takes place? Should isOkay be false?
-
- IsConnected = isOkay;
- return isOkay;
+ return IsConnected;
}
- protected override TdsPacketColumnInfoResult ProcessColumnInfo ()
+ protected override TdsDataColumnCollection ProcessColumnInfo ()
{
byte precision;
byte scale;
int totalLength = Comm.GetTdsShort ();
int bytesRead = 0;
- TdsPacketColumnInfoResult result = new TdsPacketColumnInfoResult ();
+ TdsDataColumnCollection result = new TdsDataColumnCollection ();
while (bytesRead < totalLength) {
scale = 0;
precision = 0;
int bufLength = -1;
- //int dispSize = -1;
byte[] flagData = new byte[4];
for (int i = 0; i < 4; i += 1) {
flagData[i] = Comm.GetByte ();
bytesRead += 1;
}
- int index = result.Add (new TdsSchemaInfo ());
- result[index].NumericPrecision = precision;
- result[index].NumericScale = scale;
- result[index].ColumnSize = bufLength;
- result[index].ColumnName = ColumnNames[index];
- result[index].ColumnType = columnType;
- result[index].BaseTableName = tableName;
- result[index].AllowDBNull = nullable;
- result[index].IsReadOnly = !writable;
+ int index = result.Add (new TdsDataColumn ());
+ result[index]["NumericPrecision"] = precision;
+ result[index]["NumericScale"] = scale;
+ result[index]["ColumnSize"] = bufLength;
+ result[index]["ColumnName"] = ColumnNames[index];
+ result[index]["ColumnType"] = columnType;
+ result[index]["BaseTableName"] = tableName;
+ result[index]["AllowDBNull"] = nullable;
+ result[index]["IsReadOnly"] = !writable;
}
- //int skipLength = totalLength - bytesRead;
- //if (skipLength != 0)
- //throw new TdsException ("skipping");
-
return result;
}