예제 #1
0
        //Public Function Update(where As String, Optional wherePresente As Boolean = True, Optional ByRef sql As Ogg = Nothing, Optional nuovaConn As NuovaConn = NuovaConn.seNecessario, Optional strConn As StrConnessione = Nothing,
        //                       Optional commitRollback As CommitRoll = CommitRoll.commitRollback, Optional timeOutQuery As Int32 = 0, Optional logMess As Mess = Nothing) As Boolean

        //    If IsNothing(logMess) Then logMess = New Mess(Tipi.err, log.errUserText)
        //    If IsNothing(where) Then where = ""

        //    If wherePresente = True AndAlso where = "" Then 'Serve poichè inibisce la possibilità di eseguire la query senza la parte where
        //        logMess.testoDaLoggare = "ricevuto 'wherePresente' a true, ma ricevuto 'where' a nothing o vuoto"
        //        log.Acc(New Mess(Tipi.err, log.errUserText, logMess.testoDaLoggare))
        //        Return False
        //    End If

        //    If IsNothing(sql) Then sql = New Ogg

        //    Dim query, qrySet, val As String, col As Colonna

        //    For Each proprietàCol As Reflection.FieldInfo In Me.GetType.GetFields  'Scorro tutti i field della classe che eredita da TabellaBase alla ricerca delle colonne
        //        If proprietàCol.FieldType<> GetType(Colonna) Then Continue For
        //        col = proprietàCol.GetValue(Me)
        //        If col.ident = True Then Continue For  'Se è identity non va nella Update
        //        val = col.valXqry

        //        If (val = "NULL" OrElse val = "DEFAULT") AndAlso col.valNull = False Then Continue For

        //        qrySet += col.nm & "=" & val & ", "
        //    Next

        //    If ValidaBusinessLogic(qryUpd, logMess:=logMess) = False Then Return False

        //    qrySet = RimuoviFinale(qrySet, ", ")

        //    If where<> "" Then where = " WHERE " & where

        //    query = qryUpd & nmTab & " SET " & qrySet & where

        //    If sql.ExecNoQuery(query, commitRollback:=commitRollback, nuovaConn:=nuovaConn, strConn:=strConn, timeOutQuery:=timeOutQuery, logMess:=logMess) = False Then Return False

        //    If commitRollback = CommitRoll.commitRollback Then EventoEseguitaQuery(qryUpd)

        //    Return True
        //End Function

        public bool Delete(string where, bool wherePresente = true, NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, CommitRoll commitRollback = CommitRoll.commitRollback,
                           Int32 timeOutQuery = 0, Mess logMess = null)
        {
            SqlObj sql = null;

            return(Delete(where, wherePresente, ref sql, nuovaConn, strConn, commitRollback, timeOutQuery, logMess));
        }
예제 #2
0
        //public bool Insert(Optional selecDeiValori As String = "", Optional ByRef sql As Ogg = Nothing, Optional nuovaConn As NuovaConn = NuovaConn.seNecessario, Optional strConn As StrConnessione = Nothing,
        //                       Optional commitRollback As CommitRoll = CommitRoll.commitRollback, Optional timeOutQuery As Int32 = 0, Optional logMess As Mess = Nothing) As Boolean

        //    If IsNothing(logMess) Then logMess = New Mess(Tipi.err, log.errUserText)
        //    If IsNothing(sql) Then sql = New Ogg

        //    Dim query As String

        //    If IsNothing(selecDeiValori) = True OrElse selecDeiValori = "" Then

        //        Dim col As Colonna, qryTestata, qryValori As String, valori As New List(Of String), primaCol As Boolean, valXqry As List(Of String)
        //        primaCol = True

        //        For Each proprietàCol As Reflection.FieldInfo In Me.GetType.GetFields  'Scorro tutti i field della classe che eredita da TabellaBase alla ricerca delle colonne
        //            If proprietàCol.FieldType<> GetType(Colonna) Then Continue For
        //            col = proprietàCol.GetValue(Me)
        //            If col.ident = True Then Continue For  'Se è identity non va nella insert

        //            qryTestata += col.nm & ", "

        //            If primaCol = True Then
        //                For Each tmpVal In col.valXqryList
        //                    valori.Add(tmpVal)
        //                Next

        //                primaCol = False

        //            Else '2° col in poi

        //                valXqry = col.valXqryList 'valXqryList al suo interno cicla i valori per renderli compatibili con sql, quindi la richiamo solamente una volta per le prestazioni
        //                If valori.Count<> valXqry.Count Then
        //                    log.Acc(New Mess(Tipi.err, log.errUserText, "per la tabella:<" & nmTab & ">, la colonna:<" & col.nm & "> ha un numero valori di:<" & valXqry.Count & "> mentre la prima colonna ne prevedeva:<" & valori.Count & "> la insert sarà annullata"))
        //                    Return False
        //                End If

        //                For i = 0 To valori.Count - 1
        //                    valori(i) += ", " & valXqry(i)
        //                Next

        //            End If

        //        Next

        //        If ValidaBusinessLogic(qryIns, logMess:=logMess) = False Then Return False

        //        qryTestata = RimuoviFinale(qryTestata, ", ")

        //        For Each gruppoValore In valori
        //            qryValori += "(" & gruppoValore & "), "
        //        Next

        //        qryValori = RimuoviFinale(qryValori, ", ")

        //        query = qryIns & nmTab & " (" & qryTestata & ") VALUES " & qryValori

        //    Else
        //        If ValidaBusinessLogic(qryUpd, selecDeiValori, logMess:=logMess) = False Then Return False

        //        query = qryIns & nmTab & " " & selecDeiValori

        //    End If


        //    If sql.ExecNoQuery(query, commitRollback:=commitRollback, nuovaConn:=nuovaConn, strConn:=strConn, timeOutQuery:=timeOutQuery, logMess:=logMess) = False Then Return False

        //    If commitRollback = CommitRoll.commitRollback Then EventoEseguitaQuery(qryIns)

        //    Return True
        //End Function

        //Public Function Update(where As String, Optional wherePresente As Boolean = True, Optional ByRef sql As Ogg = Nothing, Optional nuovaConn As NuovaConn = NuovaConn.seNecessario, Optional strConn As StrConnessione = Nothing,
        //                       Optional commitRollback As CommitRoll = CommitRoll.commitRollback, Optional visualLog As Boolean = True, Optional timeOutQuery As Int32 = 0, Optional ByRef descErr As String = "") As Boolean

        public bool UpdateWithPKValue(NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, CommitRoll commitRollback = CommitRoll.commitRollback,
                                      Int32 timeOutQuery  = 0, Mess logMess = null)
        {
            SqlObj sql = null;

            return(UpdateWithPKValue(ref sql, nuovaConn, strConn, commitRollback, timeOutQuery, logMess));
        }
예제 #3
0
        public bool Delete(string where, bool wherePresente, ref SqlObj sql, NuovaConn nuovaConn, StrConnection strConn, CommitRoll commitRollback, Int32 timeOutQuery, Mess logMess)
        {
            if (logMess == null)
            {
                logMess = new Mess(LogType.ERR, Log.main.errUserText);
            }
            if (where == null)
            {
                where = "";
            }

            if (wherePresente == true && where == "")   //Serve poichè inibisce la possibilità di eseguire la query senza la parte where
            {
                Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "ricevuto 'wherePresente' a true, ma ricevuto 'where' a nothing o vuoto"));
                return(false);
            }

            if (sql == null)
            {
                sql = new SqlObj();
            }

            string query;

            if (where != "")
            {
                where = " WHERE " + where;
            }

            if (ValidaBusinessLogic(Sql.del, where, logMess: logMess) == false)
            {
                return(false);
            }

            query = Sql.del + Nm + where;

            if (sql.ExecNoQuery(query, commitRollback: commitRollback, nuovaConn: nuovaConn, strConn: strConn, timeOutQuery: timeOutQuery, logMess: logMess) == false)
            {
                return(false);
            }

            if (commitRollback == CommitRoll.commitRollback)
            {
                EventoEseguitaQuery(Sql.del);
            }

            return(true);
        }
예제 #4
0
        public bool UpdateWithPKValue(ref SqlObj sql, NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, CommitRoll commitRollback = CommitRoll.commitRollback,
                                      Int32 timeOutQuery = 0, Mess logMess = null)
        {
            string where, val; Column col;
            where = "";

            foreach (FieldInfo proprietàCol in this.GetType().GetFields())
            {  //Scorro tutti i field della classe che eredita da TabellaBase alla ricerca delle colonne
                if (proprietàCol.FieldType != typeof(Column))
                {
                    continue;
                }
                col = (Column)proprietàCol.GetValue(this);

                if (col.PrimKey == false)
                {
                    continue;                        //Se non è PrimKey la scarto
                }
                val = col.ValXqry;

                if (val == "NULL" || val == "DEFAULT")
                {
                    Log.main.Add(new Mess(LogType.Warn, Log.main.warnUserText, "Non è stata valorizzata la colonna chiave:<" + col.Nm + ">"));
                    return(false);
                }

                where += col.Nm + "=" + val + " AND ";
            }

            if (where == "")
            {
                Log.main.Add(new Mess(LogType.Warn, Log.main.warnUserText, "Nella tabella non sono presenti campi chiave"));
                return(false);
            }

            where = where.RemoveFinal("AND ");

            return(Update(where, true, ref sql, nuovaConn, strConn, commitRollback, timeOutQuery, logMess));
        }
예제 #5
0
        public bool ExecNoQuery(string query, CommitRoll commitRollback = CommitRoll.commitRollback, NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, Int32 timeOutQuery = 0, Mess logMess = null)
        {
            if (logMess == null)
            {
                logMess = new Mess(LogType.ERR, Log.main.errUserText);
            }
            logMess.testoDaLoggare = "";

            Thread thread; Exception thrEx = null; bool esito; string testoTmp;

            if (PreExec(true, query, ref strConn, nuovaConn, ref timeOutQuery, logMess) == false)
            {
                return(false);
            }

            esito  = false;
            thread = Thr.AvviaNuovo(() => esito = ThrENQ_Exec(out thrEx));

            if (Thr.AttesaCompletamento(ref thread, timeOutQuery) == false)
            { //qua non faccio rollback poichè presumo che la connessione remota sia andata persa, se DB in locale non può andare in timeout
                logMess.testoDaLoggare = "query:<" + cmd.CommandText + "> andata in timeOut:<" + timeOutQuery + ">";
                Log.main.Add(logMess);
                return(false);
            }

            if (esito == false)
            {
                try
                {
                    if (commitRollback == CommitRoll.commitRollback || commitRollback == CommitRoll.soloRollback)
                    {
                        tra.Rollback();
                        this.DisconnettiDB();
                    }
                }
                catch (Exception ex)
                {
                    logMess.testoDaVisual  = ""; //Non visualizzo nulla poichè c'è il l'altro log sotto
                    logMess.testoDaLoggare = "eccezione durante rollback, ex.Mess:<" + ex.Message + ">, query:<" + query + ">";
                    Log.main.Add(logMess);
                }

                if (thrEx != null)
                {
                    if (FiltraEccezioniQuery(thrEx) == true)
                    {
                        logMess.testoDaVisual = "";
                        logMess.tipo          = LogType.Warn;
                    }
                    testoTmp = "ex.mess:<" + thrEx.Message + ">";
                }
                else
                {
                    testoTmp = "il thread ThrENQ_Exec è ritornato false ma senza eccezioni";
                }


                logMess.testoDaLoggare = "query:<" + cmd.CommandText + ">, " + testoTmp;
                Log.main.Add(logMess);
                return(false);
            }

            try
            {
                if (commitRollback == CommitRoll.commitRollback)
                {
                    tra.Commit();
                    this.DisconnettiDB();
                }
            }
            catch (Exception ex)
            {
                if (FiltraEccezioniCommit(ex) == true)
                {
                    logMess.testoDaVisual = "";
                    logMess.tipo          = LogType.Warn;
                }

                logMess.testoDaLoggare = "errore durante 'sqlTra.Commit()', ex.Mess:<" + ex.Message + ">, query:<" + query + ">";
                Log.main.Add(logMess);
                return(false);
            }

            return(true);
        }
예제 #6
0
        //ATTENZIONE res se non è un ref non funziona
        public bool ExecQuery <T1>(string query, ref T1 res, QryOut @out = QryOut.dataTable, NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, int timeOutQuery = 0, Mess logMess = null)
        {   //Attenzione: l'out come Datatable costa di più in termini di cpu, dataReader costa meno
            if (logMess == null)
            {
                logMess = new Mess(LogType.ERR, Log.main.errUserText);
            }
            logMess.testoDaLoggare = "";

            Thread thread; Exception thrEx = null; bool esito; string testoTmp;

            if (PreExec(true, query, ref strConn, nuovaConn, ref timeOutQuery, logMess) == false)
            {
                return(false);
            }

            if (res == null)
            {
                this.@out = @out;
            }
            else
            {
                if (res.GetType() == typeof(DataTable))
                {
                    this.@out = QryOut.dataTable;
                }
                else if (res.GetType() == typeof(OleDbDataReader))
                {
                    this.@out = QryOut.dataReader;
                }
                else
                {
                    logMess.testoDaLoggare = "ricevuto res con tipo disatteso, res.GetType.Name:<" + res.GetType().Name + ">";
                    Log.main.Add(logMess);
                    return(false);
                }
            }

            esito = false;
            //se si perde la connessione prima di eseguire cmd.ExecuteReader() (può succede per DB remoto quando si è già connessi, quindi con nuovaConn=False) passano 47 secondi prima che ritorna l'errore data provider interno 30,
            thread = Thr.AvviaNuovo(() => esito = ThrEQ_Exec(ref thrEx), ApartmentState.MTA); //Attenzione se STA, alla 'resOle.Close()' c'è l'eccezione: Impossibile utilizzare oggetti COM separati dai relativi RCW sottostanti.

            if (Thr.AttesaCompletamento(ref thread, timeOutQuery) == false)
            {
                logMess.testoDaLoggare = "query:<" + cmd.CommandText + "> andata in timeOut:<" + timeOutQuery + ">";
                Log.main.Add(logMess);
                return(false);
            }

            if (esito == false)
            {
                if (thrEx != null)
                {
                    if (FiltraEccezioniQuery(thrEx) == true)
                    {
                        logMess.testoDaVisual = "";
                        logMess.tipo          = LogType.Warn;
                    }
                    testoTmp = "ex.mess:<" + thrEx.Message + ">";
                }
                else
                {
                    testoTmp = "il thread ThrEQ_Exec è ritornato false ma senza eccezioni";
                }

                logMess.testoDaLoggare = "query:<" + cmd.CommandText + ">, " + testoTmp;
                Log.main.Add(logMess);
                return(false);
            }
            //Ho dovuto eseguire la resDt.Load(cmd.ExecuteReader()) nel delegato poichè se esegiuvo la resDt.Load(DataReader) qua da la seguente eccezione
            //Impossibile eseguire il cast di oggetti COM di tipo 'System.__ComObject' in tipi di interfaccia 'IRowset'. L'operazione non è stata completata perché la chiamata QueryInterface sul componente COM per l'interfaccia con IID '{ 0C733A7C - 2A1C - 11CE - ADE5 - 00AA0044773D}
            //non è riuscita a causa del seguente errore: Interfaccia non supportata. (Eccezione da HRESULT: 0x80004002 (E_NOINTERFACE)).

            if (res != null)
            {
                if (this.@out == QryOut.dataTable)
                {
                    res = (T1)(dynamic)ResDt;
                }
                else if (this.@out == QryOut.dataReader)
                {
                    res = (T1)(dynamic)ResOle;
                }
            }

            return(true);
        }
예제 #7
0
        public bool ExecQuery(string query, QryOut @out = QryOut.dataTable, NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, int timeOutQuery = 0, Mess logMess = null)
        {
            object res = null;

            return(ExecQuery(query, ref res, @out: @out, nuovaConn: nuovaConn, strConn: strConn, timeOutQuery: timeOutQuery, logMess: logMess));
        }
예제 #8
0
        private bool PreExec(bool isQuery, string query, ref StrConnection strConn, NuovaConn nuovaConn, ref Int32 timeOutQuery, Mess logMess)
        {
            if (strConn != null)
            {
                this.connStr = strConn;
            }
            if (this.connStr == null)
            {
                if (App.Db.ConnString != null)
                {
                    this.connStr = App.Db.ConnString;
                }
                else
                {
                    logMess.testoDaLoggare = "ricevuto strConn a nothing, Me.strConn è nothing e App.Db.ConnString è nothing, nessuna stringa di connessione disponibile";
                    Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, logMess.testoDaLoggare));  //Qui ci vuole sempre errore indipendentemente da tipoLog, per questo faccio un nuovo mess
                    return(false);
                }
            }

            if (this.connStr.IsInizializzata == false)
            {
                if (this.connStr.InizializzaSingoliCampi() == false)
                {
                    return(false);
                }
            }


            if (timeOutQuery == 0)
            { //se timeOutQuery=0 Carica timeout della config a meno che non sia locale (in questo caso attesa di tempo sempre infinita)
                if (this.connStr.DbRemoto == false)
                {
                    timeOutQuery = -1;
                }                      //Attesa di tempo infinita
                else if (isQuery == true)
                {
                    timeOutQuery = Sql.config.timeOutQuery;
                }
                else
                {
                    timeOutQuery = Sql.config.timeOutNonQuery;
                }
            }
            else if (timeOutQuery < -1)
            {
                logMess.testoDaLoggare = "ricevuto timeOutQuery inferiore a -1";
                Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, logMess.testoDaLoggare)); //Qui ci vuole sempre errore indipendentemente da tipoLog, per questo faccio un nuovo mess
                return(false);
            }

            switch (nuovaConn)
            { //Sono state messe in ordine di probabilità
            case NuovaConn.seNecessario:
                if (cmd.Connection == null || cmd.Connection.State != ConnectionState.Open)
                {
                    if (ConnettiDB(logMess) == false)
                    {
                        return(false);
                    }
                }
                break;

            case NuovaConn.no:     //Controllo che sia tutto ok per una nuova query, ma non devo fare altro
                if (cmd.Connection == null)
                {
                    logMess.testoDaLoggare = "nuovaConn = no ma cmd.Connection.State è nothing";
                    Log.main.Add(new Mess(LogType.ERR, "", logMess.testoDaLoggare));
                    return(false);
                }

                if (cmd.Connection.State != ConnectionState.Open)
                {
                    logMess.testoDaLoggare = "nuovaConn = no ma cmd.Connection.State diverso da open, state:<" + cmd.Connection.State.ToString() + ">";
                    Log.main.Add(new Mess(LogType.Warn, "", logMess.testoDaLoggare));
                    return(false);
                }
                break;

            case NuovaConn.si:
                if (ConnettiDB(logMess) == false)
                {
                    return(false);
                }
                if (this.connStr.DbRemoto == true)
                {
                    if (cmd.Connection == null || cmd.Connection.State != ConnectionState.Open)
                    {
                        return(false);
                    }
                }
                break;

            default:
                logMess.testoDaLoggare = "valore disatteso per nuovaConn:<" + nuovaConn.ToString() + ">";
                Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, logMess.testoDaLoggare));     //Qui ci vuole sempre errore indipendentemente da tipoLog
                return(false);
            }


            //If nuovaConn = True Then
            //    If ConnettiDB(Me.strConn, visualErr) = False Then Return False
            //    If Me.strConn.dbRemoto = True Then
            //        If IsNothing(cmd.Connection) = True OrElse cmd.Connection.State <> ConnectionState.Open Then Return False
            //    End If
            //Else
            //    If IsNothing(cmd.Connection) = False AndAlso cmd.Connection.State <> ConnectionState.Open Then 'In questo caso comunque sia non posso fare connettiDB(poichè potrebbero essere una serie di insert con ...
            //        log.Acc(New Mess(Tipi.avv, "", "nuovaConn = false ma cmd.Connection.State diverso da open, state:<" & cmd.Connection.State.ToString & ">")) '...commit finale, quindi fallirà l'esecuzione della query)
            //    End If
            //End If

            cmd.CommandText = query + "  --***Stack sub: " + Util.GetCallStack();

            return(true);
        }
예제 #9
0
        public bool Update(string where, bool wherePresente, ref SqlObj sql, NuovaConn nuovaConn, StrConnection strConn, CommitRoll commitRollback, Int32 timeOutQuery, Mess logMess)
        {
            if (logMess == null)
            {
                logMess = new Mess(LogType.ERR, Log.main.errUserText);
            }
            if (where == null)
            {
                where = "";
            }

            if (wherePresente == true && where == "")   //Serve poichè inibisce la possibilità di eseguire la query senza la parte where
            {
                logMess.testoDaLoggare = "ricevuto 'wherePresente' a true, ma ricevuto 'where' a nothing o vuoto";
                Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, logMess.testoDaLoggare));
                return(false);
            }

            if (sql == null)
            {
                sql = new SqlObj();
            }

            string query, qrySet, val; Column col;

            qrySet = "";

            foreach (FieldInfo proprietàCol in this.GetType().GetFields())    //Scorro tutti i field della classe che eredita da TabellaBase alla ricerca delle colonne
            {
                if (proprietàCol.FieldType != typeof(Column))
                {
                    continue;
                }
                col = (Column)proprietàCol.GetValue(this);

                if (col.Ident == true)
                {
                    continue;                     //Se è identity non va nella Update
                }
                val = col.ValXqry;

                if ((val == "NULL" || val == "DEFAULT") && col.ValNull == false)
                {
                    continue;
                }

                qrySet += col.Nm + "=" + val + ", ";
            }

            if (ValidaBusinessLogic(Sql.upd, logMess: logMess) == false)
            {
                return(false);
            }

            qrySet = qrySet.RemoveFinal(", ");

            if (where != "")
            {
                where = " WHERE " + where;
            }

            query = Sql.upd + Nm + " SET " + qrySet + where;

            if (sql.ExecNoQuery(query, commitRollback: commitRollback, nuovaConn: nuovaConn, strConn: strConn, timeOutQuery: timeOutQuery, logMess: logMess) == false)
            {
                return(false);
            }

            if (commitRollback == CommitRoll.commitRollback)
            {
                EventoEseguitaQuery(Sql.upd);
            }

            return(true);
        }
예제 #10
0
        public bool Insert(string selecDeiValori, ref SqlObj sql, NuovaConn nuovaConn, StrConnection strConn, CommitRoll commitRollback, Int32 timeOutQuery, Mess logMess)
        {
            if (logMess == null)
            {
                logMess = new Mess(LogType.ERR, Log.main.errUserText);
            }
            if (sql == null)
            {
                sql = new SqlObj();
            }

            string query;

            if (selecDeiValori == null || selecDeiValori == "")
            {
                Column col; string qryTestata, qryValori; List <string> valori = new List <String>(); bool primaCol; List <string> valXqry;
                primaCol   = true;
                qryTestata = qryValori = "";

                foreach (FieldInfo proprietàCol in this.GetType().GetFields())
                {  //Scorro tutti i field della classe che eredita da TabellaBase alla ricerca delle colonne
                    if (proprietàCol.FieldType != typeof(Column))
                    {
                        continue;
                    }

                    col = (Column)proprietàCol.GetValue(this);
                    if (col.Ident == true)
                    {
                        continue;                     //Se è identity non va nella insert
                    }
                    qryTestata += col.Nm + ", ";

                    if (primaCol == true)
                    {
                        foreach (string tmpVal in col.ValXqryList)
                        {
                            valori.Add(tmpVal);
                        }

                        primaCol = false;
                    }
                    else
                    {                              //2° col in poi
                        valXqry = col.ValXqryList; //valXqryList al suo interno cicla i valori per renderli compatibili con sql, quindi la richiamo solamente una volta per le prestazioni
                        if (valori.Count != valXqry.Count)
                        {
                            Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "per la tabella:<" + Nm + ">, la colonna:<" + col.Nm + "> ha un numero valori di:<" + valXqry.Count + "> mentre la prima colonna ne prevedeva:<" + valori.Count + "> la insert sarà annullata"));
                            return(false);
                        }
                        for (int i = 0; i < valori.Count; i++)
                        {
                            valori[i] += ", " + valXqry[i];
                        }
                    }
                }

                if (ValidaBusinessLogic(Sql.ins, logMess: logMess) == false)
                {
                    return(false);
                }

                qryTestata = qryTestata.RemoveFinal(", ");

                foreach (string gruppoValore in valori)
                {
                    qryValori += "(" + gruppoValore + "), ";
                }

                qryValori = qryValori.RemoveFinal(", ");

                query = Sql.ins + Nm + " (" + qryTestata + ") VALUES " + qryValori;
            }
            else
            {
                if (ValidaBusinessLogic(Sql.upd, selecDeiValori, logMess: logMess) == false)
                {
                    return(false);
                }
                query = Sql.ins + Nm + " " + selecDeiValori;
            }

            if (sql.ExecNoQuery(query, commitRollback: commitRollback, nuovaConn: nuovaConn, strConn: strConn, timeOutQuery: timeOutQuery, logMess: logMess) == false)
            {
                return(false);
            }

            if (commitRollback == CommitRoll.commitRollback)
            {
                EventoEseguitaQuery(Sql.ins);
            }

            return(true);
        }
예제 #11
0
 public bool Insert(ref SqlObj sql, string selecDeiValori = "", NuovaConn nuovaConn = NuovaConn.seNecessario, StrConnection strConn = null, CommitRoll commitRollback = CommitRoll.commitRollback, Int32 timeOutQuery = 0,
                    Mess logMess = null)
 {
     return(Insert(selecDeiValori, ref sql, nuovaConn, strConn, commitRollback, timeOutQuery, logMess));
 }