/// <summary> /// Gets column schema information about an OLE table /// </summary> /// <param name="tableName">Name of the table</param> /// <returns>DataTable with schema information</returns> public override DataSets.TableColumnSchema.ColumnsDataTable GetTableColumnSchema(string tableName) { OleDbConnection conn = this.GetNativeConnection(); try { OpenConnection(conn); DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, tableName, null }); DataSets.TableColumnSchema schema = new Epi.DataSets.TableColumnSchema(); schema.Merge(dt); return schema.Columns; } catch (Exception ex) { throw new GeneralException("Could not get table column schema for." + tableName, ex); } finally { CloseConnection(conn); } }
///// <summary> ///// Gets Primary_Keys schema information about a SQL table ///// </summary> ///// <param name="tableName">Name of the table</param> ///// <returns>DataTable with schema information</returns> //public override DataSets.TableKeysSchema.Primary_KeysDataTable GetTableKeysSchema(string tableName) //{ // OleDbConnection conn = new OleDbConnection("Provider=SQLOleDb;" + connectionString); // try // { // OpenConnection(conn); // DataTable t = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new object[] { null, null, tableName }); // DataSets.TableKeysSchema schema = new Epi.DataSets.TableKeysSchema(); // schema.Merge(t); // return schema.Primary_Keys; // } // finally // { // CloseConnection(conn); // } //} /// <summary> /// Gets column schema information about an OLE table /// </summary> /// <param name="tableName">Name of the table</param> /// <returns>DataTable with schema information</returns> public override DataSets.TableColumnSchema.ColumnsDataTable GetTableColumnSchema(string tableName) { try { DataTable table = this.GetSchema("Columns", tableName); // IS_NULLABLE and DATA_TYPE are different data types for non OleDb DataTables. DataSets.TableColumnSchema tableColumnSchema = new Epi.DataSets.TableColumnSchema(); tableColumnSchema.Merge(table, false, MissingSchemaAction.Ignore); return tableColumnSchema.Columns; } catch (Exception ex) { throw new GeneralException("Could not get table column schema for " + tableName + ".", ex); } }
/// <summary> /// Gets column schema information about an MySQL table /// </summary> /// <param name="tableName">Name of the table</param> /// <returns>DataTable with schema information</returns> public override Epi.DataSets.TableColumnSchema.ColumnsDataTable GetTableColumnSchema(string tableName) { DataTable table = this.GetSchema("Columns", tableName); DataTable tableToMerge = table.Copy(); tableToMerge.Rows.Clear(); string isNullableCol = table.Rows[0].ItemArray[6].ToString(); if (isNullableCol.Equals("YES")) { } else { tableToMerge.Rows[0].ItemArray[6] = "false"; tableToMerge.Rows[0].ItemArray[6] = Boolean.Parse(tableToMerge.Rows[0].ItemArray[6].ToString()); } //string datatype = table.Rows[0].ItemArray[7].ToString(); DataSets.TableColumnSchema tableColumnSchema = new Epi.DataSets.TableColumnSchema(); //string dc = tableColumnSchema.Columns.IS_NULLABLEColumn.DataType.FullName; tableColumnSchema.Merge(tableToMerge); return tableColumnSchema.Columns; }