private void cboDatabaseList_TextChanged(object sender, EventArgs e) { TdConnectionStringBuilder stringBuilder = new TdConnectionStringBuilder(); stringBuilder.CommandTimeout = 300; stringBuilder.ConnectionTimeout = 100; stringBuilder.DataSource = host; stringBuilder.UserId = uid; stringBuilder.Password = pwd; using (TdConnection dbConnection = new TdConnection(stringBuilder.ConnectionString)) { dbConnection.Open(); TdDataAdapter adapter = new TdDataAdapter(); DataTable dt = new DataTable(); TdCommand myCommand = new TdCommand("select tablename from dbc.TablesVX where databasename='" + cboDatabaseList.Text + "'", dbConnection); TdDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { cboTables.Items.Add(myReader[0].ToString().Trim()); } myReader.Close(); myCommand.Dispose(); } }
private void populateComboes() { TdConnectionStringBuilder stringBuilder = new TdConnectionStringBuilder(); stringBuilder.CommandTimeout = 300; stringBuilder.ConnectionTimeout = 100; stringBuilder.DataSource = host; stringBuilder.UserId = uid; stringBuilder.Password = pwd; using (TdConnection dbConnection = new TdConnection(stringBuilder.ConnectionString)) { dbConnection.Open(); TdDataAdapter adapter = new TdDataAdapter(); DataTable dt = new DataTable(); TdCommand myCommand = new TdCommand("select databasename from dbc.databases", dbConnection); TdDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { cboDatabaseList.Items.Add(myReader[0].ToString().Trim()); } myReader.Close(); myCommand.Dispose(); } }
private void RunTeradata(List <SQLResult> result, string cmd) { try { TdCommand toGo = this.TdConnection.CreateCommand(); toGo.CommandTimeout = 3600 * 12; toGo.CommandText = cmd; TdDataReader reader = toGo.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int nCol = reader.FieldCount; SQLResult newItem = new SQLResult(); if (nCol > 0) { newItem.Column0 = reader.IsDBNull(0) ? String.Empty : reader.GetValue(0).ToString(); } if (nCol > 1) { newItem.Column1 = reader.IsDBNull(1) ? String.Empty : reader.GetValue(1).ToString(); } if (nCol > 2) { newItem.Column2 = reader.IsDBNull(2) ? String.Empty : reader.GetValue(2).ToString(); } if (nCol > 3) { newItem.Column3 = reader.IsDBNull(3) ? String.Empty : reader.GetValue(3).ToString(); } if (nCol > 4) { newItem.Column4 = reader.IsDBNull(4) ? String.Empty : reader.GetValue(4).ToString(); } if (nCol > 5) { newItem.Column5 = reader.IsDBNull(5) ? String.Empty : reader.GetValue(5).ToString(); } if (nCol > 6) { newItem.Column6 = reader.IsDBNull(6) ? String.Empty : reader.GetValue(6).ToString(); } result.Add(newItem); } } reader.Close(); toGo.Dispose(); } catch (Exception ex) { throw; } }
static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(o => { Utils utils = new Utils(); DataTable excel = utils.ImportExceltoDatatable(o.inExcel, "Queries"); DirectoryInfo od = new DirectoryInfo(o.outDir); od.Create(); DataTable dtSummary = new DataTable(); dtSummary.Columns.Add(new DataColumn("SSASModel", typeof(String))); dtSummary.Columns.Add(new DataColumn("TableName", typeof(String))); dtSummary.Columns.Add(new DataColumn("TestResults", typeof(String))); dtSummary.Columns.Add(new DataColumn("TDQueryStartTime", typeof(DateTime))); dtSummary.Columns.Add(new DataColumn("TDQueryEndTime", typeof(DateTime))); dtSummary.Columns.Add(new DataColumn("TDQueryExecutionTime(minutes)", typeof(System.Double))); dtSummary.Columns.Add(new DataColumn("SSASQueryStartTime", typeof(DateTime))); dtSummary.Columns.Add(new DataColumn("SSASQueryEndTime", typeof(DateTime))); dtSummary.Columns.Add(new DataColumn("SSASQueryExecutionTime(minutes)", typeof(System.Double))); dtSummary.Columns.Add(new DataColumn("Exception", typeof(String))); dtSummary.Columns.Add(new DataColumn("TDQuery", typeof(String))); dtSummary.Columns.Add(new DataColumn("DAX", typeof(String))); foreach (DataRow row in excel.Rows) { string ssasModel = row["SSAS_MODEL"].ToString(); string tableName = row["TABLE_NAME"].ToString(); string tdQuery = row["TD_QUERY"].ToString(); string daxQuery = row["DAX"].ToString(); DateTime tdStartTime = DateTime.Now, tdEndTime = DateTime.Now, SSASStartTime = DateTime.Now, SSASEndTime = DateTime.Now; if (tableName.ToString().Equals("")) { continue; } DataRow drSummary = dtSummary.NewRow(); drSummary["SSASModel"] = ssasModel; drSummary["TableName"] = tableName; drSummary["TDQuery"] = tdQuery; drSummary["DAX"] = daxQuery; drSummary["TestResults"] = "Failed"; Console.WriteLine("---------------------------------------------------------------"); Console.WriteLine(ssasModel + " -> " + tableName); using (var workbook = new XLWorkbook()) { try { Console.WriteLine(tdQuery); TdConnection cn = new TdConnection(o.Server); cn.Open(); TdCommand cmd = null; TdDataAdapter adapter = null; DataTable dtt = new DataTable(); tdStartTime = DateTime.Now; try { cmd = new TdCommand(tdQuery, cn); cmd.CommandTimeout = 1200; adapter = new TdDataAdapter(cmd); tdStartTime = DateTime.Now; adapter.Fill(dtt); tdEndTime = DateTime.Now; workbook.Worksheets.Add(dtt, "TD"); cmd.Connection.Close(); cmd.Dispose(); adapter.Dispose(); } catch (Exception e) { tdEndTime = DateTime.Now; cmd.Connection.Close(); cmd.Dispose(); adapter.Dispose(); throw e; } drSummary["TDQueryStartTime"] = tdStartTime; drSummary["TDQueryEndTime"] = tdEndTime; drSummary["TDQueryExecutionTime(minutes)"] = (double)tdEndTime.Subtract(tdStartTime).Seconds / 60; //ADOTabularConnection conx = new ADOTabularConnection(@"Data Source = .; Catalog = AW;", AdomdType.AnalysisServices); System.Data.DataTable dt = new DataTable(); ADOTabularConnection conx = null; try { conx = new ADOTabularConnection(o.SSAS, ADOTabular.Enums.AdomdType.AnalysisServices); if (!ssasModel.Trim().Equals("")) { conx.ChangeDatabase(ssasModel); } Console.WriteLine("--------------------DAX---------------------------"); Console.WriteLine(daxQuery); SSASStartTime = DateTime.Now; drSummary["SSASQueryStartTime"] = SSASStartTime; dt = conx.ExecuteDaxQueryDataTable(daxQuery); SSASEndTime = DateTime.Now; conx.Close(); conx.Dispose(); } catch (Exception e) { SSASEndTime = DateTime.Now; conx.Close(); conx.Dispose(); throw e; } drSummary["SSASQueryEndTime"] = SSASEndTime; drSummary["SSASQueryExecutionTime(minutes)"] = (double)SSASEndTime.Subtract(SSASStartTime).Seconds / 60; int noOfRows = dt.Rows.Count; if (noOfRows > MAX_ROWS) { dt = dt.Rows.Cast <DataRow>().Take(MAX_ROWS).CopyToDataTable(); } workbook.Worksheets.Add(dt, "SSAS"); DataTable ret = utils.getDifferentRecords(dtt, dt); DataTable dtOutput = new DataTable(); dtOutput.Columns.Add(new DataColumn("SSASModel", typeof(String))); dtOutput.Columns.Add(new DataColumn("TableName", typeof(String))); dtOutput.Columns.Add(new DataColumn("TDQuery", typeof(String))); dtOutput.Columns.Add(new DataColumn("DAX", typeof(String))); dtOutput.Columns.Add(new DataColumn("TestResults", typeof(String))); dtOutput.Columns.Add(new DataColumn("TDQueryStartTime", typeof(DateTime))); dtOutput.Columns.Add(new DataColumn("TDQueryEndTime", typeof(DateTime))); dtOutput.Columns.Add(new DataColumn("TDQueryExecutionTime(minutes)", typeof(System.Double))); dtOutput.Columns.Add(new DataColumn("SSASQueryStartTime", typeof(DateTime))); dtOutput.Columns.Add(new DataColumn("SSASQueryEndTime", typeof(DateTime))); dtOutput.Columns.Add(new DataColumn("SSASQueryExecutionTime(minutes)", typeof(System.Double))); DataRow dr = dtOutput.NewRow(); dr["SSASModel"] = ssasModel; dr["TableName"] = tableName; dr["TDQuery"] = tdQuery; dr["DAX"] = daxQuery; dr["TDQueryStartTime"] = tdStartTime; dr["TDQueryEndTime"] = tdEndTime; dr["TDQueryExecutionTime(minutes)"] = (double)tdEndTime.Subtract(tdStartTime).Seconds / 60; dr["SSASQueryStartTime"] = SSASStartTime; dr["SSASQueryEndTime"] = SSASEndTime; dr["SSASQueryExecutionTime(minutes)"] = (double)SSASEndTime.Subtract(SSASStartTime).Seconds / 60; if (noOfRows == 0) { //tableName = tableName + "_NODATA"; dr["TestResults"] = "No data"; drSummary["TestResults"] = "No data"; } else if (ret.Rows.Count > 0) { workbook.Worksheets.Add(ret, "ERRORS"); //tableName = tableName + "_FAILED"; dr["TestResults"] = "Failed"; drSummary["TestResults"] = "Failed"; } else { //tableName = tableName + "_PASSED"; dr["TestResults"] = "Passed"; drSummary["TestResults"] = "Passed"; } dtOutput.Rows.Add(dr); workbook.Worksheets.Add(dtOutput, "TestOutput"); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); tableName = tableName + "_Exception"; DataTable ex = new DataTable("Exception"); ex.Columns.AddRange(new DataColumn[2] { new DataColumn("ERROR1"), new DataColumn("ERROR2") }); drSummary["Exception"] = e.Message; ex.Rows.Add("Failed", e.Message); ex.Rows.Add("", e.StackTrace); workbook.Worksheets.Add(ex, "Exception"); } finally { dtSummary.Rows.Add(drSummary); workbook.SaveAs(od.FullName + "\\" + tableName + ".xlsx"); XLWorkbook summaryworkbook = new XLWorkbook(); summaryworkbook.Worksheets.Add(dtSummary, "TestSummary"); summaryworkbook.SaveAs(od.FullName + "\\TestSummary.xlsx"); } } } }); }
static void readTeradata() { string db_name = @"DPRD_SSL_MDM_V"; // @"LabBICC_Test";LabBICC_FIN_DYI string queryTemplate = @" SELECT TableName, tablekind, case tablekind when 'V' then RequestText else null end as RequestText FROM dbc.tablesv WHERE tablekind in ('V', 'T') AND databasename IN ('{0}') AND TableName = 'vD_GeoSite' --AND TableName LIKE 'vD_Equipment_%' "; //and (TableName like 'MSBI_vF_Fixed%' or TableName like 'MSBI_vD_Report%') // AND TableName like 'MSBI_%' //in ('MSBI_vD_KeyFigureGroup', 'vD_KeyFigureGroup', 'vD_KeyFigureGroupCateg') DbObjectMaster objMaster = new DbObjectMaster(); objMaster.DefaultDatabase = db_name; string queryString = String.Format(queryTemplate, db_name); TdConnection cn = new TdConnection(); string connectionString = @"Data Source=maersk6;Database=LabBICC_Test;User Id=UADL_BICC_LOADUSER;Password=Lab@BICC123;Connection Timeout=300;"; string obj_text = "", obj_name = "", obj_type = ""; using (TdConnection connection = new TdConnection(connectionString)) { //connection.ConnectionTimeout = 300; //covered by connection string TdCommand cmd = new TdCommand(queryString, connection); cmd.CommandTimeout = 180; //cmd.Parameters.Add(new TdParameter("@viewname", "MSBI_vD_Company")); //cmd.CommandText = queryString; Console.WriteLine("Acquiring the connection...."); connection.Open(); Console.WriteLine("Getting database object list...."); TdDataReader reader = cmd.ExecuteReader(); //Console.WriteLine("{0} tables found.", reader.RecordsAffected); while (reader.Read()) { obj_name = reader["TableName"].ToString().Trim(); obj_type = reader["tablekind"].ToString().Trim().ToUpper(); obj_text = reader["RequestText"].ToString().Trim(); //str = Convert.ToString(cmd.ExecuteScalar()); //str = (string)cmd.ExecuteScalar(); //obj_text = compressQueryText(obj_text); //str = "[" + str + "]"; obj_name = obj_name.IndexOf(".") >= 0 ? obj_name : db_name + "." + obj_name; //DbObject obj = new DbObject(obj_name, obj_type, objMaster, db_name, obj_text); DbObject obj = objMaster.AddNew(obj_name, obj_type, db_name, obj_text); Console.WriteLine(obj_name); //Console.WriteLine(obj_text); Console.WriteLine("::: source objects :::"); foreach (DbObject src in obj.Sources.Values) { Console.WriteLine(src.Name); } Console.WriteLine("*******************************************"); //objMaster.Add(obj); } cmd.Dispose(); connection.Close(); } objMaster.BuildReferences(); //var json = ApiResponse //var json = JsonConvert.SerializeObject(objMaster); //this gets all objects and user drills down to their sources (if any) //this way some objects may appear in different branches of the tree DbObjectTree tree = objMaster.getDbObjectTree(); //this starts from the objects that have no targets (no one is sourced from them) //and user drills down to the sources, nvigating to the other objects this way //DbObjectTree tree = objMaster.getDbObjectTreeFlowEnd(); tree.GroupChildrenBySchema(); tree.SortTree(); tree.AddIcons(); //tree.CleanParents(); var json = JsonConvert.SerializeObject(tree); //Console.WriteLine(json); File.WriteAllText(@"C:\TEMP\views.json", json); //File.WriteAllText(@"\\SCRBADLDK003868\db\views.json", json); }
public int EjecutarConsultaAgregacionNumerales(RC_ConsultaAgregacionNumerales consulta) { var result = 0; DateTime centuryBegin = new DateTime(2001, 1, 1); DateTime currentDate = DateTime.Now; long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks; TimeSpan elapsedSpan = new TimeSpan(elapsedTicks); int lote = Convert.ToInt32(elapsedSpan.TotalSeconds); using (TdConnection oSqlConnection = new TdConnection(Cnn)) { try { oSqlConnection.Open(); using (TdCommand oSqlCmd = new TdCommand()) { oSqlCmd.Parameters.Clear(); oSqlCmd.CommandText = $"{instanciaStage}.{SpAgregacionNumerales}"; oSqlCmd.CommandType = CommandType.StoredProcedure; oSqlCmd.CommandTimeout = int.MaxValue; oSqlCmd.Connection = oSqlConnection; TdParameter Id_Estructura = oSqlCmd.CreateParameter(); Id_Estructura.DbType = DbType.String; Id_Estructura.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Id_Estructura"; oSqlCmd.Parameters.Add(Id_Estructura); Id_Estructura.Value = consulta.Id_Estructura; TdParameter Fecha_Consulta = oSqlCmd.CreateParameter(); Fecha_Consulta.DbType = DbType.DateTime; Id_Estructura.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Fecha_Consulta"; oSqlCmd.Parameters.Add(Fecha_Consulta); Fecha_Consulta.Value = consulta.Fecha_Consulta; TdParameter Id_Fuente = oSqlCmd.CreateParameter(); Id_Fuente.DbType = DbType.String; Id_Estructura.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Id_Fuente"; oSqlCmd.Parameters.Add(Id_Fuente); Id_Fuente.Value = consulta.Id_Fuente; TdParameter Fecha_Inicial = oSqlCmd.CreateParameter(); Fecha_Inicial.DbType = DbType.DateTime; Id_Estructura.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Fecha_Inicial"; oSqlCmd.Parameters.Add(Fecha_Inicial); Fecha_Inicial.Value = consulta.Fecha_Inicial; TdParameter Fecha_Final = oSqlCmd.CreateParameter(); Fecha_Final.DbType = DbType.DateTime; Fecha_Final.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Fecha_Final"; oSqlCmd.Parameters.Add(Fecha_Final); Fecha_Final.Value = consulta.Fecha_Final; TdParameter Id_Periodicidad = oSqlCmd.CreateParameter(); Id_Periodicidad.DbType = DbType.String; Id_Periodicidad.Direction = ParameterDirection.Input; Id_Estructura.ParameterName = "Id_Periodicidad"; oSqlCmd.Parameters.Add(Id_Periodicidad); Id_Periodicidad.Value = consulta.Id_Periodicidad; result = oSqlCmd.ExecuteNonQuery(); result = 1; oSqlCmd.Dispose(); oSqlConnection.Close(); } } catch (SqlException e) { DeleteConsultaAgregacionNumerales(consulta); result = -1; } catch (TdException e) { DeleteConsultaAgregacionNumerales(consulta); result = -1; } catch (FormatException e) { DeleteConsultaAgregacionNumerales(consulta); result = -1; } catch (OverflowException e) { DeleteConsultaAgregacionNumerales(consulta); result = -1; } } return(result); }
private int GuardarConsultaAgregacionNumerales(RC_ConsultaAgregacionNumerales consulta) { var result = 0; DateTime centuryBegin = new DateTime(2001, 1, 1); DateTime currentDate = DateTime.Now; long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks; TimeSpan elapsedSpan = new TimeSpan(elapsedTicks); int lote = Convert.ToInt32(elapsedSpan.TotalSeconds); using (TdConnection oSqlConnection = new TdConnection(Cnn)) { try { oSqlConnection.Open(); using (TdCommand oSqlCmd = new TdCommand()) { oSqlCmd.Parameters.Clear(); oSqlCmd.CommandText = "INSERT INTO " + instancia + ".V_RC_ConsultaAgregacionNumerales " + "(Sk_Consulta, Id_Estructura, Fecha_Consulta, Id_Fuente, Fecha_Inicial, Fecha_Final," + "Id_Periodicidad, Nombre_UsuarioCreacion, Fecha_Creacion, Sk_Lote, Sk_Lote_Upd," + "Cod_Severidad)" + " VALUES " + " ((SEL COALESCE(MAX(Sk_Consulta), 0) + 1 FROM " + instancia + ".V_RC_ConsultaAgregacionNumerales)," + "?, ?, ?, ?, ?,?,?, CURRENT_DATE, ?, null, 1); "; oSqlCmd.CommandType = CommandType.Text; oSqlCmd.CommandTimeout = 30; oSqlCmd.Connection = oSqlConnection; TdParameter Id_Estructura = oSqlCmd.CreateParameter(); Id_Estructura.DbType = DbType.String; Id_Estructura.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Estructura); Id_Estructura.Value = consulta.Id_Estructura; TdParameter Fecha_Consulta = oSqlCmd.CreateParameter(); Fecha_Consulta.DbType = DbType.DateTime; Id_Estructura.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Consulta); Fecha_Consulta.Value = consulta.Fecha_Consulta; TdParameter Id_Fuente = oSqlCmd.CreateParameter(); Id_Fuente.DbType = DbType.String; Id_Estructura.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Fuente); Id_Fuente.Value = consulta.Id_Fuente; TdParameter Fecha_Inicial = oSqlCmd.CreateParameter(); Fecha_Inicial.DbType = DbType.DateTime; Id_Estructura.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Inicial); Fecha_Inicial.Value = consulta.Fecha_Inicial; TdParameter Fecha_Final = oSqlCmd.CreateParameter(); Fecha_Final.DbType = DbType.DateTime; Fecha_Final.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Final); Fecha_Final.Value = consulta.Fecha_Final; TdParameter Id_Periodicidad = oSqlCmd.CreateParameter(); Id_Periodicidad.DbType = DbType.String; Id_Periodicidad.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Periodicidad); Id_Periodicidad.Value = consulta.Id_Periodicidad; TdParameter Nombre_UsuarioCreacion = oSqlCmd.CreateParameter(); Nombre_UsuarioCreacion.DbType = DbType.String; Nombre_UsuarioCreacion.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Nombre_UsuarioCreacion); Nombre_UsuarioCreacion.Value = consulta.Nombre_UsuarioCreacion; TdParameter loteP = oSqlCmd.CreateParameter(); loteP.DbType = DbType.Int32; loteP.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(loteP); loteP.Value = lote; result = oSqlCmd.ExecuteNonQuery(); oSqlCmd.Dispose(); oSqlConnection.Close(); } } catch (SqlException) { result = -1; } catch (TdException) { result = -1; } catch (FormatException) { result = -1; } catch (OverflowException) { result = -1; } } return(result); }
public int DeleteConsultaAgregacionNumerales(RC_ConsultaAgregacionNumerales consulta) { var result = 0; DateTime centuryBegin = new DateTime(2001, 1, 1); DateTime currentDate = DateTime.Now; long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks; TimeSpan elapsedSpan = new TimeSpan(elapsedTicks); int lote = Convert.ToInt32(elapsedSpan.TotalSeconds); using (TdConnection oSqlConnection = new TdConnection(Cnn)) { try { oSqlConnection.Open(); using (TdCommand oSqlCmd = new TdCommand()) { oSqlCmd.Parameters.Clear(); oSqlCmd.CommandText = " DELETE FROM " + instancia + ".V_RC_ResultadoAgregacionNumerales " + " WHERE Sk_Consulta= (SEL sk_consulta FROM " + instancia + ".V_RC_ConsultaAgregacionNumerales WHERE Id_Estructura= ? AND Fecha_Consulta= ? AND Id_Fuente=? AND Fecha_Inicial=? AND Fecha_Final=? " + " AND Id_Periodicidad=?);" + " DELETE FROM " + instancia + ".V_RC_DetalleResultadoAgregacionNumerales " + " WHERE Sk_Consulta= (SEL sk_consulta FROM " + instancia + ".V_RC_ConsultaAgregacionNumerales WHERE Id_Estructura= ? AND Fecha_Consulta= ? AND Id_Fuente=? AND Fecha_Inicial=? AND Fecha_Final=? " + " AND Id_Periodicidad=?);" + "DELETE FROM " + instancia + ".V_RC_ConsultaAgregacionNumerales " + " WHERE Id_Estructura= ? AND Fecha_Consulta= ? AND Id_Fuente=? AND Fecha_Inicial=? AND Fecha_Final=? " + " AND Id_Periodicidad=?;"; oSqlCmd.CommandType = CommandType.Text; oSqlCmd.CommandTimeout = 30; oSqlCmd.Connection = oSqlConnection; TdParameter Id_Estructura = oSqlCmd.CreateParameter(); Id_Estructura.DbType = DbType.String; Id_Estructura.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Estructura); Id_Estructura.Value = consulta.Id_Estructura; TdParameter Fecha_Consulta = oSqlCmd.CreateParameter(); Fecha_Consulta.DbType = DbType.DateTime; Fecha_Consulta.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Consulta); Fecha_Consulta.Value = consulta.Fecha_Consulta; TdParameter Id_Fuente = oSqlCmd.CreateParameter(); Id_Fuente.DbType = DbType.String; Id_Fuente.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Fuente); Id_Fuente.Value = consulta.Id_Fuente; TdParameter Fecha_Inicial = oSqlCmd.CreateParameter(); Fecha_Inicial.DbType = DbType.DateTime; Fecha_Inicial.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Inicial); Fecha_Inicial.Value = consulta.Fecha_Inicial; TdParameter Fecha_Final = oSqlCmd.CreateParameter(); Fecha_Final.DbType = DbType.DateTime; Fecha_Final.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Final); Fecha_Final.Value = consulta.Fecha_Final; TdParameter Id_Periodicidad = oSqlCmd.CreateParameter(); Id_Periodicidad.DbType = DbType.String; Id_Periodicidad.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Periodicidad); Id_Periodicidad.Value = consulta.Id_Periodicidad; TdParameter Id_Estructura2 = oSqlCmd.CreateParameter(); Id_Estructura2.DbType = DbType.String; Id_Estructura2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Estructura2); Id_Estructura2.Value = consulta.Id_Estructura; TdParameter Fecha_Consulta2 = oSqlCmd.CreateParameter(); Fecha_Consulta2.DbType = DbType.DateTime; Fecha_Consulta2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Consulta2); Fecha_Consulta2.Value = consulta.Fecha_Consulta; TdParameter Id_Fuente2 = oSqlCmd.CreateParameter(); Id_Fuente2.DbType = DbType.String; Id_Fuente2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Fuente2); Id_Fuente2.Value = consulta.Id_Fuente; TdParameter Fecha_Inicial2 = oSqlCmd.CreateParameter(); Fecha_Inicial2.DbType = DbType.DateTime; Fecha_Inicial2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Inicial2); Fecha_Inicial2.Value = consulta.Fecha_Inicial; TdParameter Fecha_Final2 = oSqlCmd.CreateParameter(); Fecha_Final2.DbType = DbType.DateTime; Fecha_Final2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Final2); Fecha_Final2.Value = consulta.Fecha_Final; TdParameter Id_Periodicidad2 = oSqlCmd.CreateParameter(); Id_Periodicidad2.DbType = DbType.String; Id_Periodicidad2.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Periodicidad2); Id_Periodicidad2.Value = consulta.Id_Periodicidad; TdParameter Id_Estructura3 = oSqlCmd.CreateParameter(); Id_Estructura3.DbType = DbType.String; Id_Estructura3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Estructura3); Id_Estructura3.Value = consulta.Id_Estructura; TdParameter Fecha_Consulta3 = oSqlCmd.CreateParameter(); Fecha_Consulta3.DbType = DbType.DateTime; Fecha_Consulta3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Consulta3); Fecha_Consulta3.Value = consulta.Fecha_Consulta; TdParameter Id_Fuente3 = oSqlCmd.CreateParameter(); Id_Fuente3.DbType = DbType.String; Id_Fuente3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Fuente3); Id_Fuente3.Value = consulta.Id_Fuente; TdParameter Fecha_Inicial3 = oSqlCmd.CreateParameter(); Fecha_Inicial3.DbType = DbType.DateTime; Fecha_Inicial3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Inicial3); Fecha_Inicial3.Value = consulta.Fecha_Inicial; TdParameter Fecha_Final3 = oSqlCmd.CreateParameter(); Fecha_Final3.DbType = DbType.DateTime; Fecha_Final3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Fecha_Final3); Fecha_Final3.Value = consulta.Fecha_Final; TdParameter Id_Periodicidad3 = oSqlCmd.CreateParameter(); Id_Periodicidad3.DbType = DbType.String; Id_Periodicidad3.Direction = ParameterDirection.Input; oSqlCmd.Parameters.Add(Id_Periodicidad3); Id_Periodicidad3.Value = consulta.Id_Periodicidad; result = oSqlCmd.ExecuteNonQuery(); oSqlCmd.Dispose(); oSqlConnection.Close(); } } catch (SqlException) { result = -1; } catch (TdException e) { result = -1; } catch (FormatException) { result = -1; } catch (OverflowException) { result = -1; } } return(result); }