//View Data public DB2DataReader ExecDataView(String sql) { if (this.ConnectDatabase() == true) { Cmd = new DB2Command(sql, Conn); Resultset = Cmd.ExecuteReader(); } return Resultset; }
public static string GetDBValueStr(DB2DataReader reader, string columnName, string defaultValue = "") { if (reader[columnName] == DBNull.Value) { return defaultValue; } else { string value = string.Empty; value = reader[columnName].ToString(); return value; } }
public static int GetDBValueInt(DB2DataReader reader, string columnName, int defaultValue = -1) { if (reader[columnName] == DBNull.Value) { return defaultValue; } else { string value = string.Empty; value = reader[columnName].ToString(); return Convert.ToInt32(value); } }
public static DateTime GetDBValueDateTime(DB2DataReader reader, string columnName, string defaultValue = "0000-01-01") { if (reader[columnName] == DBNull.Value) { return Convert.ToDateTime(defaultValue); } else { string value = string.Empty; value = reader[columnName].ToString(); return Convert.ToDateTime(value); } }
private DataTable GetSchema() { dataAdapter.SelectCommand.Connection.Open(); DB2Command cmd = new DB2Command(dataAdapter.SelectCommand.CommandText, dataAdapter.SelectCommand.Connection); DB2DataReader fake = cmd.ExecuteReader(CommandBehavior.KeyInfo); DataTable dt = fake.GetSchemaTable(); fake.Close(); dataAdapter.SelectCommand.Connection.Close(); return(dt); }
/// /// ExecuteScalar /// public object ExecuteScalar() { if ((db2Conn == null) || (db2Conn.State != ConnectionState.Open)) { throw new InvalidOperationException("Prepare needs an open connection"); } using (DB2DataReader reader = ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.SingleRow)) { if (reader.Read() && (reader.FieldCount > 0)) { return(reader[0]); } } return(null); }
public DB2DataReader ExecuteReader(CommandBehavior behavior) { if ((db2Conn == null) || (db2Conn.State != ConnectionState.Open)) { throw new InvalidOperationException("Prepare needs an open connection"); } DB2DataReader reader; ExecuteNonQueryInternal(behavior); reader = new DB2DataReader(db2Conn, this, behavior); refDataReader = new WeakReference(reader); return(reader); }
internal void ConnectionClosed() { DB2DataReader reader = null; if ((refDataReader != null) && refDataReader.IsAlive) { reader = (DB2DataReader)refDataReader.Target; } if ((reader != null) && refDataReader.IsAlive) { reader.Dispose(); refDataReader = null; } CloseStatementHandle(true); db2Trans = null; }
public static bool GetDBValueBool(DB2DataReader reader, string columnName, bool defaultValue = false) { if (reader[columnName] == DBNull.Value) { return defaultValue; } else { string value = string.Empty; value = reader[columnName].ToString(); string[] yesParas = { "1", "Y" }; if (yesParas.Contains(value)) { return true; } else { return false; } } }
public DB2DataReader ExecuteReader(CommandBehavior behavior) { if((db2Conn == null) || (db2Conn.State != ConnectionState.Open)) throw new InvalidOperationException("Prepare needs an open connection"); DB2DataReader reader; ExecuteNonQueryInternal(behavior); reader = new DB2DataReader(db2Conn, this, behavior); refDataReader = new WeakReference(reader); return reader; }
protected internal DB2SpatialExtenderFeatureDataReader( IGeometryFactory geomFactory, DB2DataReader internalReader, string geometryColumn, string oidColumn) : base(geomFactory, internalReader, geometryColumn, oidColumn) { }