Idataparameter calls the Stored Procedure

Source: Internet
Author: User
public string  GenerateExamePaper(string paperType, string driverID, string MacAddr)
        {
            int i;
            IDataParameter[] iData = new SqlParameter[4];
            iData[0] = new SqlParameter("@paperType", paperType);
            iData[1] = new SqlParameter("@driverID", driverID);
            iData[2] = new SqlParameter("@MacAddr", MacAddr);
            iData[3] = new SqlParameter("@sReturn", SqlDbType.Char, 50, ParameterDirection.Output, false, 0, 0, string.Empty, DataRowVersion.Default,null);
            string aaa = "";
            i= DbHelperSQL.RunProcedureParOut("Pro_GenerateExamePaper", iData, out aaa).ToString();

            return aaa;

        }


  /// <summary>
        /// 运行存储过程,返回影响的行数
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程參数</param>
        /// <param name="rowsAffected">影响的行数</param>

/// <param name="rowsAffected">返回output值</param>

        /// <returns></returns>
        public static int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected,out str)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                int result;
                connection.Open();
                SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);
                rowsAffected = command.ExecuteNonQuery();
                result = (int)command.Parameters["ReturnValue"].Value;
              str= (int)command.Parameters["@sReturn"].Value;
                return result;
            }
        }

IDataParameter调用存储过程

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.