2002-05-22 Daniel Morgan <danmorg@sc.rr.com>
authorDaniel Morgan <monodanmorg@yahoo.com>
Wed, 22 May 2002 02:27:20 +0000 (02:27 -0000)
committerDaniel Morgan <monodanmorg@yahoo.com>
Wed, 22 May 2002 02:27:20 +0000 (02:27 -0000)
* System.Data.SqlClient/SqlCommand.cs: more work on
building the schema table

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

mcs/class/Mono.Data.PostgreSqlClient/Mono.Data.PostgreSqlClient/PgSqlCommand.cs
mcs/class/Mono.Data.PostgreSqlClient/PgSqlCommand.cs
mcs/class/System.Data/ChangeLog
mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs

index 94a262dc525d01dfadbd24d4406b596e28cdd84a..67955710a069886416a7024486feeb51e05c352f 100644 (file)
@@ -703,6 +703,8 @@ namespace System.Data.SqlClient {
 
                internal void BuildTableSchema (IntPtr pgResult) 
                {
+                       pg_result = pgResult;
+
                        dataTableSchema = new DataTable ();
                        dataTableSchema.Columns.Add ("ColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));
@@ -715,7 +717,7 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseTableName", typeof (string));
-                       dataTableSchema.Columns.Add ("DataType", typeof (System.Type));
+                       dataTableSchema.Columns.Add ("DataType", typeof (string));
                        dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));
                        dataTableSchema.Columns.Add ("ProviderType", typeof (string));
                        dataTableSchema.Columns.Add ("IsAliased", typeof (bool));
@@ -727,13 +729,17 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("IsLong", typeof (bool));
                        dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));
 
-                       int fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       rowCount = PostgresLibrary.PQntuples(pgResult);
+                       pgtypes = new string[fieldCount];\r
+
                        DataRow schemaRow;
                        int oid;
                        string pgType;
                        DbType dbType;
+                       Type typ;
+                       DataColumn schemaCol;
                        
-
                        for (int i = 0; i < fieldCount; i += 1 )
                        {
                                oid = PostgresLibrary.PQftype (pgResult, i);
@@ -751,9 +757,16 @@ namespace System.Data.SqlClient {
                                schemaRow["BaseSchemaName"] = ""; // ? tim
                                schemaRow["BaseTableName"]  = ""; // ? tim
                                
+                               Console.WriteLine("Calling OidToTypname...");
                                pgType = PostgresHelper.OidToTypname (oid, con.Types);
+                               pgtypes[i] = pgType;
+
+                               Console.WriteLine("Calling TypnameToSqlDbType...");
                                dbType = PostgresHelper.TypnameToSqlDbType (pgType);
-                               //schemaRow["DataType"] = PostgresHelper.DbTypeToSystemType (dbType); ??? this gives a bad cast.
+                               
+                               Console.WriteLine("Calling DbTypeToSystemType...");
+                               typ = PostgresHelper.DbTypeToSystemType (dbType);
+                               schemaRow["DataType"] = typ.ToString();
 
                                schemaRow["AllowDBNull"] = false; // ? tim
                                schemaRow["ProviderType"] = ""; // ? tim
index 94a262dc525d01dfadbd24d4406b596e28cdd84a..67955710a069886416a7024486feeb51e05c352f 100644 (file)
@@ -703,6 +703,8 @@ namespace System.Data.SqlClient {
 
                internal void BuildTableSchema (IntPtr pgResult) 
                {
+                       pg_result = pgResult;
+
                        dataTableSchema = new DataTable ();
                        dataTableSchema.Columns.Add ("ColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));
@@ -715,7 +717,7 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseTableName", typeof (string));
-                       dataTableSchema.Columns.Add ("DataType", typeof (System.Type));
+                       dataTableSchema.Columns.Add ("DataType", typeof (string));
                        dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));
                        dataTableSchema.Columns.Add ("ProviderType", typeof (string));
                        dataTableSchema.Columns.Add ("IsAliased", typeof (bool));
@@ -727,13 +729,17 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("IsLong", typeof (bool));
                        dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));
 
-                       int fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       rowCount = PostgresLibrary.PQntuples(pgResult);
+                       pgtypes = new string[fieldCount];\r
+
                        DataRow schemaRow;
                        int oid;
                        string pgType;
                        DbType dbType;
+                       Type typ;
+                       DataColumn schemaCol;
                        
-
                        for (int i = 0; i < fieldCount; i += 1 )
                        {
                                oid = PostgresLibrary.PQftype (pgResult, i);
@@ -751,9 +757,16 @@ namespace System.Data.SqlClient {
                                schemaRow["BaseSchemaName"] = ""; // ? tim
                                schemaRow["BaseTableName"]  = ""; // ? tim
                                
+                               Console.WriteLine("Calling OidToTypname...");
                                pgType = PostgresHelper.OidToTypname (oid, con.Types);
+                               pgtypes[i] = pgType;
+
+                               Console.WriteLine("Calling TypnameToSqlDbType...");
                                dbType = PostgresHelper.TypnameToSqlDbType (pgType);
-                               //schemaRow["DataType"] = PostgresHelper.DbTypeToSystemType (dbType); ??? this gives a bad cast.
+                               
+                               Console.WriteLine("Calling DbTypeToSystemType...");
+                               typ = PostgresHelper.DbTypeToSystemType (dbType);
+                               schemaRow["DataType"] = typ.ToString();
 
                                schemaRow["AllowDBNull"] = false; // ? tim
                                schemaRow["ProviderType"] = ""; // ? tim
index 7e3fe64121b94ea149e8c764e70541c01af0771c..5428ee715634121b406e32508f041385a2b08fbe 100644 (file)
@@ -1,3 +1,8 @@
+2002-05-22  Daniel Morgan <danmorg@sc.rr.com>
+
+       * System.Data.SqlClient/SqlCommand.cs: more work on 
+       building the schema table
+
 2002-05-22  Tim Coleman <tim@timcoleman.com>
        * System.Data.SqlClient/SqlCommand.cs: preliminary work
        on getting the schema table correctly built.
index 94a262dc525d01dfadbd24d4406b596e28cdd84a..67955710a069886416a7024486feeb51e05c352f 100644 (file)
@@ -703,6 +703,8 @@ namespace System.Data.SqlClient {
 
                internal void BuildTableSchema (IntPtr pgResult) 
                {
+                       pg_result = pgResult;
+
                        dataTableSchema = new DataTable ();
                        dataTableSchema.Columns.Add ("ColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));
@@ -715,7 +717,7 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));
                        dataTableSchema.Columns.Add ("BaseTableName", typeof (string));
-                       dataTableSchema.Columns.Add ("DataType", typeof (System.Type));
+                       dataTableSchema.Columns.Add ("DataType", typeof (string));
                        dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));
                        dataTableSchema.Columns.Add ("ProviderType", typeof (string));
                        dataTableSchema.Columns.Add ("IsAliased", typeof (bool));
@@ -727,13 +729,17 @@ namespace System.Data.SqlClient {
                        dataTableSchema.Columns.Add ("IsLong", typeof (bool));
                        dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));
 
-                       int fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       fieldCount = PostgresLibrary.PQnfields (pgResult);
+                       rowCount = PostgresLibrary.PQntuples(pgResult);
+                       pgtypes = new string[fieldCount];\r
+
                        DataRow schemaRow;
                        int oid;
                        string pgType;
                        DbType dbType;
+                       Type typ;
+                       DataColumn schemaCol;
                        
-
                        for (int i = 0; i < fieldCount; i += 1 )
                        {
                                oid = PostgresLibrary.PQftype (pgResult, i);
@@ -751,9 +757,16 @@ namespace System.Data.SqlClient {
                                schemaRow["BaseSchemaName"] = ""; // ? tim
                                schemaRow["BaseTableName"]  = ""; // ? tim
                                
+                               Console.WriteLine("Calling OidToTypname...");
                                pgType = PostgresHelper.OidToTypname (oid, con.Types);
+                               pgtypes[i] = pgType;
+
+                               Console.WriteLine("Calling TypnameToSqlDbType...");
                                dbType = PostgresHelper.TypnameToSqlDbType (pgType);
-                               //schemaRow["DataType"] = PostgresHelper.DbTypeToSystemType (dbType); ??? this gives a bad cast.
+                               
+                               Console.WriteLine("Calling DbTypeToSystemType...");
+                               typ = PostgresHelper.DbTypeToSystemType (dbType);
+                               schemaRow["DataType"] = typ.ToString();
 
                                schemaRow["AllowDBNull"] = false; // ? tim
                                schemaRow["ProviderType"] = ""; // ? tim