virtual protected void CalculateLastInsertedId(string qstring, DbCommand cmd) { if (qstring.ToLower().IndexOf("insert").Equals(0)) { lastInsertedID = ""; try { cmd.CommandText = GetLastInsertedIdSql(); cmd.Prepare(); RunnerDBReader rdr = cmd.ExecuteReader(); rdr.Connection = cmd.Connection; if (rdr.Read()) { lastInsertedID = new XVar(rdr[0]); } } catch (Exception e) { } } }
/** * An interface stub * Fetch a result row as a numeric array * @param Mixed qHanle The query handle * @return Array */ public XVar fetch_numarray(dynamic qHanle) { //db_fetch_numarray if (qHanle != null) { RunnerDBReader reader = (RunnerDBReader)qHanle; if (reader.Read()) { XVar result = new XVar(); for (int i = 0; i < reader.FieldCount; i++) { result.SetArrayItem(i, reader[i]); } return(result); } } return(XVar.Array()); }
/** * An interface stub * @param Mixed qHandle * @param Number pageSize * @param Number page */ public XVar seekPage(XVar qHandle, XVar pageSize, XVar page) { //db_pageseek if (page == 1) { return(null); } if (qHandle != null) { RunnerDBReader reader = qHandle as RunnerDBReader; for (int i = 0; i < pageSize * (page - 1); i++) { if (!reader.Read()) { return(null); } } } return(null); }
public override void db_multipleInsertQuery(XVar qstringArray, XVar table = null, XVar isIdentityOffNeeded = null) { try { DbConnection connection = connectionsPool.FreeConnection; if (connection.State != System.Data.ConnectionState.Open) { connection.Open(); } DbCommand cmd = GetCommand(); cmd.Connection = connection; if (isIdentityOffNeeded) { cmd.CommandText = "SET IDENTITY_INSERT " + table.ToString() + " ON"; cmd.Prepare(); cmd.ExecuteNonQuery(); } foreach (var qstring in qstringArray.GetEnumerator()) { if (GlobalVars.dDebug) { MVCFunctions.EchoToOutput(qstring.Value.ToString() + "<br />"); } GlobalVars.strLastSQL = qstring.Value; cmd.CommandText = qstring.Value.ToString(); cmd.ExecuteNonQuery(); } if (isIdentityOffNeeded) { cmd.CommandText = "SET IDENTITY_INSERT " + table.ToString() + " OFF"; cmd.Prepare(); cmd.ExecuteNonQuery(); } else { cmd.CommandText = "select @@IDENTITY as indent"; cmd.Prepare(); RunnerDBReader rdr = cmd.ExecuteReader(); rdr.Connection = cmd.Connection; if (rdr.Read()) { lastInsertedID = new XVar(rdr["indent"]); } } connection.Close(); } catch (Exception e) { if (!silentMode) { if (!MVCFunctions.HandleError()) { throw e; } } } }