Jelajahi Sumber

2002-11-03 Tim Coleman ([email protected])
* System.Data.SqlClient/SqlCommand.cs:
Use SET NO_BROWSETABLE ON when CommandBehavior is KeyInfo
* System.Data.SqlClient/SqlDataReader.cs:
Get more schema info if available
* list:
Add Mono.Data.TdsClient.Internal.TdsColumnStatus

svn path=/trunk/mcs/; revision=8791

Tim Coleman 23 tahun lalu
induk
melakukan
17cbe76c5e

+ 8 - 0
mcs/class/System.Data/ChangeLog

@@ -1,3 +1,11 @@
+2002-11-03  Tim Coleman ([email protected])
+	* System.Data.SqlClient/SqlCommand.cs:
+		Use SET NO_BROWSETABLE ON when CommandBehavior is KeyInfo
+	* System.Data.SqlClient/SqlDataReader.cs:
+		Get more schema info if available
+	* list:
+		Add Mono.Data.TdsClient.Internal.TdsColumnStatus
+
 2002-11-02  Tim Coleman ([email protected]) 
 	* System.Data.SqlClient/SqlCommand.cs:
 		Change to use sp_executesql to run regular text queries.

+ 14 - 14
mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs

@@ -171,23 +171,23 @@ namespace System.Data.SqlClient {
 			if (commandType == CommandType.StoredProcedure)
 				return BuildProcedureCall (commandText, parameters);
 
+			string sql = String.Empty;
 			if ((behavior & CommandBehavior.KeyInfo) > 0)
-				commandText += " FOR BROWSE";
-
-			if (commandType == CommandType.Text)
-				return BuildExec ();
-
-			if (commandType == CommandType.TableDirect)
-				return BuildExec (String.Format ("select * from {0}", commandText));
-
-			throw new InvalidOperationException ("The CommandType was invalid.");
+				sql = "SET FMTONLY OFF; SET NO_BROWSETABLE ON;";
+	
+			switch (commandType) {
+			case CommandType.Text :
+				sql += commandText;
+				break;
+			case CommandType.TableDirect :
+				sql += String.Format ("select * from {0}", commandText);
+				break;
+			default:
+				throw new InvalidOperationException ("The CommandType was invalid.");
+			}
+			return BuildExec (sql);
 		}
 
-		private string BuildExec ()
-		{
-			return BuildExec (commandText);	
-		}
-	
 		private string BuildExec (string sql)
 		{
 			StringBuilder parms = new StringBuilder ();

+ 20 - 18
mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs

@@ -405,37 +405,39 @@ namespace System.Data.SqlClient {
 						break;
 				}
 
+				// set default values
+				row ["AllowDBNull"] = true;
+				row ["BaseCatalogName"] = DBNull.Value;
+				row ["BaseColumnName"] = DBNull.Value;
+				row ["BaseSchemaName"] = DBNull.Value;
+				row ["BaseTableName"] = DBNull.Value;
+				row ["ColumnName"] = DBNull.Value;
+				row ["IsUnique"] = false;
+				row ["NumericPrecision"] = DBNull.Value;
+				row ["NumericScale"] = DBNull.Value;
+
+				// load schema values
 				row ["ColumnOrdinal"] = schema.ColumnOrdinal;
 				row ["ColumnSize"] = schema.ColumnSize;
 				row ["AllowDBNull"] = schema.AllowDBNull;
-				row ["IsReadOnly"] = schema.IsReadOnly;
+				row ["IsExpression"] = schema.IsExpression;
 				row ["IsIdentity"] = schema.IsIdentity;
+				row ["IsReadOnly"] = schema.IsReadOnly;
 				row ["IsKey"] = schema.IsKey;
 
-				// FIXME: Base Column Name and Column Name are not necessarily the same
-				if (schema.ColumnName == null)
-					row ["BaseColumnName"] = DBNull.Value;
-				else
-					row ["BaseColumnName"] = schema.ColumnName;
+				if (schema.BaseColumnName != null)
+					row ["BaseColumnName"] = schema.BaseColumnName;
 
-				if (schema.ColumnName == null)
-					row ["ColumnName"] = DBNull.Value;
-				else
+				if (schema.ColumnName != null)
 					row ["ColumnName"] = schema.ColumnName;
 
-				if (schema.TableName == null)
-					row ["BaseTableName"] = DBNull.Value;
-				else
-					row ["BaseTableName"] = schema.TableName;
+				if (schema.BaseTableName != null)
+					row ["BaseTableName"] = schema.BaseTableName;
 
-				if (schema.NumericScale == 0)
-					row ["NumericPrecision"] = DBNull.Value;
-				else
+				if (schema.NumericScale != 0)
 					row ["NumericPrecision"] = schema.NumericPrecision;
 
 				if (schema.NumericScale == 0)
-					row ["NumericScale"] = DBNull.Value;
-				else
 					row ["NumericScale"] = schema.NumericScale;
 
 				schemaTable.Rows.Add (row);

+ 1 - 0
mcs/class/System.Data/list

@@ -176,6 +176,7 @@ System.Data.SqlClient/SqlXmlTextReader.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/ITds.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds70.cs
+../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsColumnStatus.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsColumnType.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsComm.cs
 ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsContext.cs