コード例 #1
0
ファイル: DbHelperSQL.cs プロジェクト: Klutzdon/PBIMSN
 /// <summary>
 /// 执行存储过程,返回SqlDataReader ( 注意:调用该方法后,一定要对SqlDataReader进行Close )
 /// </summary>
 /// <param name="storedProcName">存储过程名</param>
 /// <param name="parameters">存储过程参数</param>
 /// <param name="processType">工序(數據庫)</param>
 /// <returns></returns>
 public static SqlDataReader RunProcedure(string storedProcName, IDataParameter[] parameters, Common.CustEnum.ProdProcess processType)
 {
     SqlConnection connection = new SqlConnection(GetProcessSQLConnString(processType));
     SqlDataReader returnReader;
     connection.Open();
     SqlCommand command = BuildQueryCommand(connection, storedProcName, parameters);
     command.CommandType = CommandType.StoredProcedure;
     returnReader = command.ExecuteReader(CommandBehavior.CloseConnection);
     return returnReader;
 }
コード例 #2
0
ファイル: DbHelperSQL.cs プロジェクト: Klutzdon/PBIMSN
        /// <summary>
        /// 獲取指定工序的數據庫連接字符
        /// </summary>
        /// <param name="processType">工序類型</param>
        /// <returns></returns>
        public static string GetProcessSQLConnString(Common.CustEnum.ProdProcess processType)
        {
            string strSQLConn = string.Empty;

            switch (processType)
            {
                case Common.CustEnum.ProdProcess.LAM:
                    strSQLConn = ConfigurationSettings.AppSettings["SQLConnSubString_LAMIMSN"];
                    break;
                case Common.CustEnum.ProdProcess.HOT:
                    strSQLConn = ConfigurationSettings.AppSettings["SQLConnSubString_HOTIMSN"];
                    break;
                case Common.CustEnum.ProdProcess.SILK:
                    strSQLConn = ConfigurationSettings.AppSettings["SQLConnSubString_SILKIMSN"];
                    break;
                default:
                    strSQLConn = string.Empty;
                    break;
            }

            return strSQLConn;
        }