コード例 #1
0
ファイル: General.cs プロジェクト: merlin2504/RD12
        public string Set(int CompanyIndex, ArrayList param, string SPName, out long ReturnValue)
        {
            ReturnValue = 0;
            try
            {
                if (DataBase.Equals("SQL"))
                {
                    SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex));
                    ReturnValue = Convert.ToInt64(dbResult.Parameters["@RETURN_VALUE"]);
                    if (ReturnValue > 0)
                    {
                        return("Success");
                    }
                    else
                    {
                        if (dbResult.Contents.Tables.Count > 0 && dbResult.Contents.Tables[0].Rows.Count > 0)
                        {
                            return("Error Message :" + dbResult.Contents.Tables[0].Rows[0]["ErrorMessage"].ToString()
                                   + "\n Error Number :" + dbResult.Contents.Tables[0].Rows[0]["ErrorNumber"].ToString()
                                   + "\n ProcedureName :" + dbResult.Contents.Tables[0].Rows[0]["ProcedureName"].ToString()
                                   + "\n ErrorLine :" + dbResult.Contents.Tables[0].Rows[0]["ErrorLine"].ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(string.Empty);
        }
コード例 #2
0
        public static SQLDBResult Execute(
            string procedureName,
            ArrayList procedureParameters, string strConnection)
        {
            SQLDBResult   result     = null;
            SqlConnection connection = null;

            try
            {
                // Get Connection and Procedure
                connection = new SqlConnection(strConnection);
                connection.Open();
                DbUtilProcedure procedure = Procedure(connection, procedureName, null);

                // Create Command
                SqlCommand command = procedure.Command(connection, procedureParameters);
                command.CommandTimeout = 0;
                result = new SQLDBResult();
                SqlDataAdapter adapter = new SqlDataAdapter(command);

                // Execute and Fill Results
                adapter.Fill(result.Contents);
                foreach (SqlParameter cparam in command.Parameters)
                {
                    switch (cparam.Direction)
                    {
                    case ParameterDirection.InputOutput:
                    case ParameterDirection.Output:
                    case ParameterDirection.ReturnValue:

                        result.Parameters[cparam.ParameterName] = cparam.Value;
                        break;

                    case ParameterDirection.Input:
                    default:

                        // do nothing
                        break;
                    }
                }
            }
            catch (System.Exception e)
            {
                throw new DbUtilException(e.Message, e);
            }
            finally
            {
                if ((connection != null) &&
                    (connection.State == ConnectionState.Open))
                {
                    connection.Close();
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: General.cs プロジェクト: merlin2504/RD12
        public DataSet Get(int CompanyIndex, ArrayList param, string SPName)
        {
            DataSet ds = null;

            try
            {
                if (DataBase.Equals("SQL"))
                {
                    SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex));
                    ds = dbResult.Contents;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(ds);
        }
コード例 #4
0
ファイル: SQLAdapter.cs プロジェクト: merlin2504/RD12
        public static SQLDBResult Execute(
            string procedureName,
            ArrayList procedureParameters, string strConnection)
        {
            SQLDBResult result = null;
            SqlConnection connection = null;
            try
            {

                // Get Connection and Procedure
                connection = new SqlConnection(strConnection);
                connection.Open();
                DbUtilProcedure procedure = Procedure(connection, procedureName, null);

                // Create Command
                SqlCommand command = procedure.Command(connection, procedureParameters);
                command.CommandTimeout = 0;
                result = new SQLDBResult();
                SqlDataAdapter adapter = new SqlDataAdapter(command);

                // Execute and Fill Results
                adapter.Fill(result.Contents);
                foreach (SqlParameter cparam in command.Parameters)
                {

                    switch (cparam.Direction)
                    {

                        case ParameterDirection.InputOutput:
                        case ParameterDirection.Output:
                        case ParameterDirection.ReturnValue:

                            result.Parameters[cparam.ParameterName] = cparam.Value;
                            break;

                        case ParameterDirection.Input:
                        default:

                            // do nothing
                            break;
                    }
                }
            }
            catch (System.Exception e)
            {

                throw new DbUtilException(e.Message, e);
            }
            finally
            {

                if ((connection != null) &&
                    (connection.State == ConnectionState.Open))
                {

                    connection.Close();
                }
            }
            return result;
        }