public System.Data.OleDb.OleDbCommand OLEDBDeleteCommandObject(string strWhere, bool Prepared) { if (cmdOLEDBDelete == null) { cmdOLEDBDelete = new System.Data.OleDb.OleDbCommand(); cmdOLEDBDelete.Connection = OLEDBConn; if (m_OLEDBTrans != null) cmdOLEDBDelete.Transaction = m_OLEDBTrans; string strSQL = "Delete from " + pTablename + " WHERE " + strWhere; cmdOLEDBDelete.CommandText = strSQL; if (Prepared) cmdOLEDBDelete.Prepare(); } else { // Nur WHERE ändern ! int i = Strings.InStr(cmdOLEDBDelete.CommandText, " WHERE "); cmdOLEDBDelete.CommandText = Strings.StrLeft(cmdOLEDBDelete.CommandText, i - 1) + " WHERE " + strWhere; cmdOLEDBDelete.Transaction = m_OLEDBTrans; } return cmdOLEDBDelete; }
// <<<<<<<<<<<<<<<<<<<<<<< OLE-DB >>>>>>>>>>>>>>>>>>>>>>>> public System.Data.OleDb.OleDbCommand OLEDBInsertCommandObject(bool Prepared) { SQLColumnDefinition def; if (cmdOLEDBInsert == null) { cmdOLEDBInsert = new System.Data.OleDb.OleDbCommand(); cmdOLEDBInsert.Connection = OLEDBConn; if (m_OLEDBTrans != null) cmdOLEDBInsert.Transaction = m_OLEDBTrans; StringBuilder SB = new StringBuilder(); SB.Append("Insert into " + pTablename + " ("); SQLColumnDefinition d; bool bFlag = false; foreach (string ColumnName in ColumnNames) { d = Columns[ColumnName]; if (d.bActive) { if (bFlag) SB.Append(", "); SB.Append(ColumnName); bFlag = true; } } SB.Append(") Values ("); bFlag = false; foreach (string ColumnName in ColumnNames) { d = Columns[ColumnName]; if (d.bActive) { if (bFlag) SB.Append(", "); SB.Append("@" + Column2ParameterName(ColumnName)); bFlag = true; } } SB.Append(")"); cmdOLEDBInsert.CommandText = SB.ToString(); SetCommandParameters(ref cmdOLEDBInsert); if (Prepared) cmdOLEDBInsert.Prepare(); } // Data foreach (string ColumnName in ColumnNames) { def = Columns[ColumnName]; if (def.bActive) { cmdOLEDBInsert.Parameters["@" + Column2ParameterName(ColumnName)].Value = def.DBValue(pDBMSType); } } return cmdOLEDBInsert; }