private void btnPublishData_Click(object sender, EventArgs e) { string sQuery1 = string.Empty; string sQuery2 = string.Empty; string sQuery3 = string.Empty; string message = string.Empty; IBM.Data.DB2.DB2Connection conn = null; DataTable dt = new DataTable("Table1"); try { conn = ConnectDb(); switch (cmbTransactionType.SelectedIndex) { case 0: sQuery1 = "SELECT * FROM DEPOSIT FETCH FIRST 5 ROWS ONLY"; break; case 1: sQuery1 = "SELECT * FROM LOAN FETCH FIRST 5 ROWS ONLY"; break; } using (IBM.Data.DB2.DB2Command cmd = new IBM.Data.DB2.DB2Command(sQuery1, conn)) { IBM.Data.DB2.DB2DataReader dr = cmd.ExecuteReader(); dt.Load(dr); } conn.Close(); if (dt.Rows.Count <= 0) { message = "No Record Exist !!!"; } else { SaveData(dt); message = "Successfully Imported '" + cmbTransactionType.Text + "' Data !!!"; } } catch (Exception ex) { message = ex.Message; } MessageBox.Show(message, "Import from DB2 Utility", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/* * Método que trae las posiciones que dispone cada part number. */ private static DataTable bringResultsForPositions(string toolIdToSearch, string _ProductPartNumberId) { IBM.Data.DB2.DB2Connection conn = null; DataTable dt = new DataTable("Table1"); conn = ConnectDb(); string queryDbGetRequestedDataForPositions = @" SELECT CGSLSC.TOOL_SETUP.*, TOOL_KEY AS EXPR1, PRODUCT_PN_KEY AS EXPR2 FROM CGSLSC.TOOL_SETUP WHERE (TOOL_KEY = " + toolIdToSearch + ") AND (PRODUCT_PN_KEY = " + _ProductPartNumberId + ")"; using (IBM.Data.DB2.DB2Command cmd = new IBM.Data.DB2.DB2Command(queryDbGetRequestedDataForPositions, conn)) { IBM.Data.DB2.DB2DataReader dr = cmd.ExecuteReader(); dt.Load(dr); } conn.Close(); return(dt); }
/* * Método que devuelve el nombre del part number ID */ private static DataTable bringResultsForProductPN(string _ProductPartNumberId) { IBM.Data.DB2.DB2Connection conn = null; DataTable dt = new DataTable("Table1"); conn = ConnectDb(); string queryDbGetRequestedDataForPN = @" SELECT PART_NUMBER_KEY AS EXPR1, CGS.PART_NUMBER.* FROM CGS.PART_NUMBER WHERE (PART_NUMBER_KEY = " + _ProductPartNumberId + ")"; using (IBM.Data.DB2.DB2Command cmd = new IBM.Data.DB2.DB2Command(queryDbGetRequestedDataForPN, conn)) { IBM.Data.DB2.DB2DataReader dr = cmd.ExecuteReader(); dt.Load(dr); } conn.Close(); return(dt); }
/* * Método que trae todos los datos de la tabla TOOL_SETUP_INFO por toolId */ private static DataTable bringResultsForToolId(string toolIdToSearch) { IBM.Data.DB2.DB2Connection conn = null; DataTable dt = new DataTable("Table1"); conn = ConnectDb(); string queryDbGetRequestedDataForToolKey = @"SELECT TS_INFO_KEY, PRODUCT_PN_KEY, TOOL_KEY, ROUTE_STEP_KEY, LAST_CHANGE_TMST, RECIPE_READY, RECIPE_ID, PROGRAM_ID, CARRIER_PN_KEY, DUAL_SIDED, DUAL_LANE, PFC_MODE, LAST_SETUP_TOOL_KEY, LAST_SETUP_TOOL_STAGE FROM CGSLSC.TOOL_SETUP_INFO WHERE (TOOL_KEY = " + toolIdToSearch + ") ORDER BY LAST_CHANGE_TMST DESC"; using (IBM.Data.DB2.DB2Command cmd = new IBM.Data.DB2.DB2Command(queryDbGetRequestedDataForToolKey, conn)) { IBM.Data.DB2.DB2DataReader dr = cmd.ExecuteReader(); dt.Load(dr); } conn.Close(); return(dt); }
/// <summary> /// 加载内存 判断是否debug 非公开 /// </summary> /// <param name="errLogoFileName">errLogoFileName</param> private void newDatabase(string errLogoFileName) { if (this.con == null) { con = new IBM.Data.DB2.DB2Connection(); } command = new IBM.Data.DB2.DB2Command(); this.command.Connection = con as IBM.Data.DB2.DB2Connection; Logo = new Neusoft.FrameWork.Models.NeuLog(errLogoFileName); string debugLogoFileName = "./debugSql.log"; if (System.IO.File.Exists(debugLogoFileName)) { debugLogo = new Neusoft.FrameWork.Models.NeuLog(debugLogoFileName); bDebug = true; } else { bDebug = false; } }
public DB2DataAdapter(IBM.Data.DB2.DB2Command selectCommand) { }
public static void DeriveParameters(IBM.Data.DB2.DB2Command command) { }
private string GetColumnImage(string imageID, string column, string fileName) { string retImageFullName = ""; if (_DB2Conn == null) { return(retImageFullName); } //DB2 Access IBM.Data.DB2.DB2Command DB2cmd = null; IBM.Data.DB2.DB2DataReader DB2read = null; try { DB2cmd = new IBM.Data.DB2.DB2Command(); DB2cmd.CommandText = "SELECT " + column + " FROM DBSDESX.CHVT34A0_IMAGENS WHERE CREFARQ = '" + imageID + "'"; DB2cmd.Connection = _DB2Conn; DB2read = DB2cmd.ExecuteReader(); //System.Data.CommandBehavior.SequentialAccess); if (!DB2read.Read()) { return(retImageFullName); //not found } } catch (System.Exception ex) { throw ex; } //Read BLOB System.Text.StringBuilder sb = new System.Text.StringBuilder(); int bufferSize = 100; byte[] outByte = new byte[bufferSize]; long retval; long startIndex = 0; try { // Read bytes into outByte[] and retain the number of bytes returned. retval = DB2read.GetBytes(0, startIndex, outByte, 0, bufferSize); // Continue while there are bytes beyond the size of the buffer. while (retval == bufferSize) { //Write the buffer. (convert byte to char) for (int i = 0; i < retval; i++) { sb.Append(System.Convert.ToChar(outByte[i])); } // Reposition start index to end of last buffer and fill buffer. startIndex += bufferSize; retval = DB2read.GetBytes(0, startIndex, outByte, 0, bufferSize); } // Write the remaining buffer. (convert byte to char) for (int i = 0; i < retval; i++) { sb.Append(System.Convert.ToChar(outByte[i])); } } catch { } //Close DB2 reader try { DB2read.Close(); DB2cmd.Dispose(); } catch (System.Exception ex) { throw ex; } //Create file try { if (sb.Length > 0) { string myDocFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonPictures) + "\\"; string text = sb.ToString(); byte[] base64EncodedBytes = System.Convert.FromBase64String(text); System.IO.File.WriteAllBytes(myDocFolder + fileName, base64EncodedBytes); retImageFullName = myDocFolder + fileName; } } catch (System.Exception ex) { throw ex; } return(retImageFullName); }