private static SqlCommand FxSqlConnection(string pDatabase) { SqlConnection ObjSqlConnection = new SqlConnection(); SqlCommand ObjSqlCommand = new SqlCommand(); SqlConnectionStringBuilder ObjSqlConnectionString = FxSqlConnectionString(pDatabase); ObjSqlConnection.ConnectionString = ObjSqlConnectionString.ConnectionString; ObjSqlCommand.Connection = ObjSqlConnection; try { ObjSqlConnection.Open(); } catch { ObjSqlCommand = null; ClsFunctions.FxMessage(1, "No pudo conectarse con el servidor"); ClsFunctions.FxExit(); } ObjSqlConnectionString.Clear(); return(ObjSqlCommand); }
internal static DataTable FxSqlExecute(string pDatabase, string pSchema, string pStoredProcedure, object[][] pParameters) { DataTable ObjDt = new DataTable(); using (SqlDataAdapter ObjSqlDa = new SqlDataAdapter()) { using (SqlCommand ObjSqlCommand = FxSqlConnection(pDatabase)) { if (ObjSqlCommand != null) { if (pParameters[0] != null) { FxSqlParameters(ObjSqlCommand, pParameters); } ObjSqlCommand.CommandType = CommandType.StoredProcedure; ObjSqlCommand.CommandText = pSchema + "." + pStoredProcedure; ObjSqlDa.SelectCommand = ObjSqlCommand; try { ObjSqlDa.Fill(ObjDt); } catch { ObjDt = null; ClsFunctions.FxMessage(1, "Operación no fue completada"); ClsFunctions.FxExit(); } } if (ObjSqlCommand != null) { ObjSqlCommand.Connection.Close(); } } } return(ObjDt); }