コード例 #1
0
ファイル: AwesomeDB.min.cs プロジェクト: Riki1312/AwesomeDB
        //Esegue una query parametri: testo della query, tipo di query
        public ADB_Result Query(string query, QueryTypes queryTypes = QueryTypes.query)
        {
            try
            {
                ADB_Result ret = null;
                SqlCommand cmd = new SqlCommand();

                switch (queryTypes)
                {
                    case QueryTypes.query:
                        cmd.CommandText = query;
                        ret = new ADB_Result(then: this, dataTable: LowLevel.db.EseguiQuery(cmd));
                        break;
                    case QueryTypes.notquery:
                        cmd.CommandText = query;
                        ret = new ADB_Result(then: this, changedRecords: LowLevel.db.EseguiNonQuery(cmd));
                        break;
                    case QueryTypes.scalar:
                        cmd.CommandText = query;
                        ret = new ADB_Result(then: this, singleData: LowLevel.db.EseguiScalar(cmd));
                        break;
                }
                return ret;
            }
            catch(Exception ex)
            {
                if (Settings.DebugMode) throw new Exception(ex.Message);
                else return new ADB_Result(then: this, errorsMessage: ex.Message);
            }
        }
コード例 #2
0
ファイル: AwesomeDB.min.cs プロジェクト: Riki1312/AwesomeDB
        //- ADDDTIONAL [

        //Esegue una stored procedure parametri: nome procedura, parametri procedura
        public ADB_Result StoredProcedure(string name, string[,] parameters = null)
        {
            try
            {
                ADB_Result ret = null;
                parameters = parameters ?? new string[,] { { "", "" } };  //new string[,] { { "nomeParametro", "valore" } };

                ret = new ADB_Result(then: this, dataTable: LowLevel.RunWithParameters(CommandType.StoredProcedure, name, parameters));
                return ret;
            }
            catch (Exception ex)
            {
                if (Settings.DebugMode) throw new Exception(ex.Message);
                else return new ADB_Result(then: this, errorsMessage: ex.Message);
            }
        }