private DataTable GetTestDataTableFromDB(string testID, Sybase.Data.AseClient.AseConnection conn) { DataTable table = new DataTable(testID); using (Sybase.Data.AseClient.AseDataAdapter adapter = new Sybase.Data.AseClient.AseDataAdapter("select * from QA_PAC_TIMING where TE_REF like '"+testID+"'" ,conn)) { adapter.Fill(table); } return table; }
private void FillLocalUDTTable(DataTable gridValues) { Sybase.Data.AseClient.AseConnection conn = new Sybase.Data.AseClient.AseConnection(connectionString); PAC_TimingObject timingObject = new PAC_TimingObject(); string maxLogicalTeNumber = "PAR.TE."; try { conn.Open(); DataTable table = new DataTable("TempTable"); foreach (DataRow row in gridValues.Rows) { string selectedTe = row["closestCPUTENumber"].ToString(); string executionContext = row["executionCtx"].ToString(); using (Sybase.Data.AseClient.AseDataAdapter adapter = new Sybase.Data.AseClient.AseDataAdapter("Select * from QA_PAC_TIMING where TE_REF='"+selectedTe+"' and EXECUTION_TYPE='"+executionContext+"'" ,conn)) { int rowsNumber = adapter.Fill(table); if (rowsNumber >1) { rowsNumber = 0; } } } Sybase.Data.AseClient.AseCommand commandMaxTE = new Sybase.Data.AseClient.AseCommand("select LOGICAL_TE from QA_PAC_REFERENCES_INT where ID in (Select max(ID) from QA_PAC_REFERENCES_INT)",conn); object returnedValue = commandMaxTE.ExecuteScalar(); if (returnedValue !=null) { string[] teValueSplit = returnedValue.ToString().Split(new char[] {'.'},StringSplitOptions.RemoveEmptyEntries); Decimal teNumber = Convert.ToDecimal(teValueSplit[2]); teNumber = teNumber +1; maxLogicalTeNumber = maxLogicalTeNumber+teNumber.ToString("0000000"); } else { maxLogicalTeNumber= maxLogicalTeNumber+"0000000"; } DataTable table2 = table.Copy(); table2.Columns.Add("SELECTED_TE"); table2.Columns.Add("TE_GROUP"); table2.Columns.Add("LOGICAL_TE"); foreach (DataRow row in table2.Rows) { row["SELECTED_TE"]= row["TE_REF"].ToString(); row["TE_GROUP"] = txtInputTes.Text.Trim(); row["LOGICAL_TE"] = maxLogicalTeNumber; } dgvIntermediate.DataSource = table2; } catch (Exception ex) { CommonUtils.ShowError(ex.Message,ex); } finally { conn.Close(); } }