public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = "SELECT * FROM " + tableName; DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); try { object[] data = new object[colCount]; int ret = DataReader.GetValues(data); foreach (object o in data) { if (o == null) { Fail("GetValues() failed to retrieve the column values"); } row.Append(o.ToString()); row.Append(", "); } Log(row.ToString()); } catch (Exception e) { Fail(e); } } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { String schemaName1 = DbHelper.GetRandomString(10); String schemaName2 = DbHelper.GetRandomString(10); String tableName = DbHelper.GetRandomString(8); try { DbRandom.BuildRandomTable(schemaName1, tableName, 10); DbRandom.BuildRandomTable(schemaName2, tableName, 15); Command.CommandText = String.Format("SELECT * FROM {0}.{1}", schemaName1, tableName); DataTable table = new DataTable(); DataAdapter.Fill(table); ParseDataTable(table); Command.CommandText = String.Format("SELECT * FROM {0}.{1}", schemaName2, tableName); table.Clear(); DataAdapter.Fill(table); ParseDataTable(table); } catch (Exception e) { Fail(e); } finally { try { DbHelper.DropTable(String.Format("{0}.{1}", schemaName1, tableName)); DbHelper.DropTable(String.Format("{0}.{1}", schemaName2, tableName)); } catch (Exception e) { Fail(e); } base.Run(context); } }
public override void Run(object context) { String tableName = null; try { tableName = DbRandom.BuildRandomTable(10); int colCount = DbHelper.GetTableColumnCount(tableName); Command.CommandText = "SELECT * FROM " + tableName; DataReader = Command.ExecuteReader(); while (DataReader.Read()) { StringBuilder row = new StringBuilder(); for (int i = 0; i < colCount; i++) { try { switch (DataReader.GetDataTypeName(i)) { case "INTEGER": row.Append(DataReader.GetInt32(i)); break; case "BIGINT": row.Append(DataReader.GetInt64(i)); break; case "CHAR": row.Append(DataReader.GetChar(i)); break; case "DATE": row.Append(DataReader.GetDateTime(i)); break; case "DECIMAL": row.Append(DataReader.GetDecimal(i)); break; case "DOUBLE": row.Append(DataReader.GetDouble(i)); break; case "LONG VARCHAR": row.Append(DataReader.GetChars(i, 0, 0)); break; case "REAL": row.Append(DataReader.GetDecimal(i)); break; case "SMALLINT": row.Append(DataReader.GetInt16(i)); break; case "TIME": DateTime dt = DataReader.GetDateTime(i); Log(String.Format("DateTime.Kind = {0}", dt.Kind)); row.Append(DataReader.GetDateTime(i)); break; case "TIMESTAMP": row.Append(DataReader.GetDateTime(i)); break; case "VARCHAR": row.Append(DataReader.GetChars(i, 0, 0)); break; case "CHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "VARCHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "LONG VARCHAR FOR BIT DATA": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "BLOB": row.Append(DbHelper.ConvertToString(DataReader.GetBytes(i))); break; case "CLOB": row.Append(DataReader.GetChars(i, 0, 0)); break; default: row.Append("UNKNOWN"); break; } row.Append(", "); } catch (Exception e) { Fail(e); } } Log(row.ToString()); } } catch (Exception e) { Fail(e); } finally { try { DbRandom.DropTable(tableName); } catch (Exception e) { Fail(e); } base.Run(context); } }