+ // VARADHAN: TDS 8 Debugging
+ //Console.WriteLine ("Tds80.cs: In ProcessColumnInfo... entry");
+ TdsDataColumnCollection result = new TdsDataColumnCollection ();
+ int numColumns = Comm.GetTdsShort ();
+ //Console.WriteLine ("Column count={0}", numColumns); TDS 8 Debugging
+ for (int i = 0; i < numColumns; i += 1) {
+ byte[] flagData = new byte[4];
+ for (int j = 0; j < 4; j += 1)
+ flagData[j] = Comm.GetByte ();
+
+ bool nullable = (flagData[2] & 0x01) > 0;
+ //bool caseSensitive = (flagData[2] & 0x02) > 0;
+ bool writable = (flagData[2] & 0x0c) > 0;
+ bool autoIncrement = (flagData[2] & 0x10) > 0;
+ bool isIdentity = (flagData[2] & 0x10) > 0;
+
+ TdsColumnType columnType = (TdsColumnType) (Comm.GetByte () & 0xff);
+ //Console.WriteLine ("Actual ColumnType: {0}", columnType); TDS 8 Debugging
+
+ if ((byte) columnType == 0xef)
+ columnType = TdsColumnType.NChar;
+
+ TdsColumnType xColumnType = columnType;
+ if (IsLargeType (columnType)) {
+ if (columnType != TdsColumnType.NChar)
+ columnType -= 128;
+ }
+
+ int columnSize;
+ string tableName = null;
+ byte[] collation = null;
+
+ if (IsBlobType (columnType)) {
+ columnSize = Comm.GetTdsInt ();
+ } else if (IsFixedSizeColumn (columnType)) {
+ columnSize = LookupBufferSize (columnType);
+ } else if (IsLargeType (xColumnType)) {
+ columnSize = Comm.GetTdsShort ();
+ } else {
+ columnSize = Comm.GetByte () & 0xff;
+ }
+
+ if (xColumnType == TdsColumnType.BigChar || xColumnType == TdsColumnType.BigNVarChar ||
+ xColumnType == TdsColumnType.BigVarChar || xColumnType == TdsColumnType.NChar ||
+ xColumnType == TdsColumnType.NVarChar || xColumnType == TdsColumnType.Text ||
+ xColumnType == TdsColumnType.NText) {
+ // Read collation for SqlServer 2000 and beyond
+ collation = Comm.GetBytes (5, true);
+ }
+
+ if (IsBlobType (columnType)) {
+ tableName = Comm.GetString (Comm.GetTdsShort ());
+ //Console.WriteLine ("Tablename: "+tableName); TDS 8 Debugging
+ }
+
+ byte precision = 0;
+ byte scale = 0;
+
+ switch (columnType) {
+ case TdsColumnType.NText:
+ case TdsColumnType.NChar:
+ case TdsColumnType.NVarChar:
+ columnSize /= 2;
+ break;
+ case TdsColumnType.Decimal:
+ case TdsColumnType.Numeric:
+ //Comm.Skip (1);
+ precision = Comm.GetByte ();
+ //Console.WriteLine ("Precision: {0}", precision); TDS 8 Debugging
+ scale = Comm.GetByte ();
+ //Console.WriteLine ("Scale: {0}", scale); TDS 8 Debugging
+ break;
+ }
+
+ string columnName = Comm.GetString (Comm.GetByte ());
+
+ TdsDataColumn col = new TdsDataColumn ();
+ result.Add (col);
+#if NET_2_0
+ col.ColumnType = columnType;
+ col.ColumnName = columnName;
+ col.IsAutoIncrement = autoIncrement;
+ col.IsIdentity = isIdentity;
+ col.ColumnSize = columnSize;
+ col.NumericPrecision = precision;
+ col.NumericScale = scale;
+ col.IsReadOnly = !writable;
+ col.AllowDBNull = nullable;
+ col.BaseTableName = tableName;
+#else
+ col ["ColumnType"] = columnType;
+ col ["ColumnName"] = columnName;
+ col ["IsAutoIncrement"] = autoIncrement;
+ col ["IsIdentity"] = isIdentity;
+ col ["ColumnSize"] = columnSize;
+ col ["NumericPrecision"] = precision;
+ col ["NumericScale"] = scale;
+ col ["IsReadOnly"] = !writable;
+ col ["AllowDBNull"] = nullable;
+ col ["BaseTableName"] = tableName;
+#endif
+ }
+ //Console.WriteLine ("Tds80.cs: In ProcessColumnInfo... exit"); TDS 8 Debugging
+ return result;