public System.Data.IDataReader GetReader(qGen.Select comando) { comando.SqlMode = this.SqlMode; return this.GetReader(comando.ToString()); }
public System.Data.DataTable Select(qGen.Select selectCommand) { selectCommand.SqlMode = this.SqlMode; return Select(selectCommand.ToString()); }
public decimal FieldDecimal(qGen.Select selectCommand) { selectCommand.SqlMode = this.SqlMode; object Res = this.ExecuteScalar(selectCommand.ToString()); if (Res == null || Res is DBNull) return 0; else return System.Convert.ToDecimal(Res); }
public Lfx.Data.Row FirstRowFromSelect(qGen.Select selectCommand) { selectCommand.SqlMode = this.SqlMode; return this.FirstRowFromSelect(selectCommand.ToString()); }
public string FieldString(qGen.Select selectCommand) { selectCommand.SqlMode = this.SqlMode; object Res = this.ExecuteScalar(selectCommand.ToString()); if (Res == null || Res is DBNull) return null; else return Res.ToString(); }
public int Insert(qGen.Insert insertCommand) { if (this.ReadOnly) throw new InvalidOperationException("No se pueden realizar cambios en la conexión de lectura"); insertCommand.SqlMode = this.SqlMode; if (this.IsOpen() == false) this.Open(); if (Lfx.Workspace.Master.TraceMode) Lfx.Workspace.Master.DebugLog(this.Handle, insertCommand.ToString()); System.Data.IDbCommand TempCommand = this.GetCommand(insertCommand); try { return TempCommand.ExecuteNonQuery(); } catch (Exception ex) { this.LogError("----------------------------------------------------------------------------"); this.LogError(ex.Message); this.LogError(TempCommand.CommandText); throw ex; } }
public int Delete(qGen.Delete deleteCommand) { if (this.ReadOnly) throw new InvalidOperationException("No se pueden realizar cambios en la conexión de lectura"); deleteCommand.SqlMode = this.SqlMode; if (this.IsOpen() == false) this.Open(); return this.ExecuteSql(deleteCommand.ToString()); }
public int Update(qGen.Update updateCommand) { if (this.ReadOnly) throw new InvalidOperationException("No se pueden realizar cambios en la conexión de lectura"); updateCommand.SqlMode = this.SqlMode; if (this.IsOpen() == false) this.Open(); using (System.Data.IDbCommand TempCommand = this.GetCommand(updateCommand)) { while (true) { try { TempCommand.Connection = this.DbConnection; this.ResetKeepAliveTimer(); int Res = TempCommand.ExecuteNonQuery(); return Res; } catch (Exception ex) { if (this.TryToRecover(ex)) { ex.Data.Add("Command", updateCommand.ToString()); throw ex; } } } } }
/// <summary> /// Exporta los campos binarios de una tabla en archivos. /// </summary> public void ExportBlobs(qGen.Select ComandoSelect, string Carpeta) { if (char.Parse(Carpeta.Substring(Carpeta.Length - 1, 1)) != System.IO.Path.DirectorySeparatorChar) Carpeta += System.Convert.ToString(System.IO.Path.DirectorySeparatorChar); using (System.Data.DataTable Tabla = Lfx.Workspace.Master.MasterConnection.Select(ComandoSelect.ToString())) { foreach (System.Data.DataRow Registro in Tabla.Rows) { foreach (System.Data.DataColumn Campo in Tabla.Columns) { if (Campo.DataType.Name == "Byte[]" && Registro[Campo.ColumnName] != null && ((byte[])(Registro[Campo.ColumnName])).Length > 5) { byte[] Contenido = ((byte[])(Registro[Campo.ColumnName])); string NombreArchivo = ComandoSelect.Tables + "_" + Campo.ColumnName + "_" + Registro[0].ToString() + ".blb"; using (System.IO.FileStream Archivo = new System.IO.FileStream(Carpeta + NombreArchivo, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write)) { Archivo.Write(Contenido, 0, Contenido.Length); Archivo.Close(); } using (System.IO.FileStream Archivo = new System.IO.FileStream(Carpeta + "blobs.lst", System.IO.FileMode.Append, System.IO.FileAccess.Write)) { System.IO.StreamWriter Escribidor = new System.IO.StreamWriter(Archivo); Escribidor.WriteLine(ComandoSelect.Tables + "," + Campo.ColumnName + "," + Tabla.Columns[0].ColumnName + "='" + Registro[0].ToString() + "'," + NombreArchivo); Escribidor.Close(); Archivo.Close(); } } } } } }