当前位置: 首页>>代码示例>>C#>>正文


C# SqlParameter.Count方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlParameter.Count方法的典型用法代码示例。如果您正苦于以下问题:C# SqlParameter.Count方法的具体用法?C# SqlParameter.Count怎么用?C# SqlParameter.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlParameter的用法示例。


在下文中一共展示了SqlParameter.Count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExcuteNoneQuery

        /// <summary>
        /// access database
        /// </summary>
        /// <param name="prostorename">Stored procedure name</param>
        /// <param name="param">array list for SqlParameter</param>
        /// <returns>result</returns>
        public static int ExcuteNoneQuery(string connectionString, string prostorename, SqlParameter[] param)
        {
            int result = -1;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = connection;
                connection.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = prostorename;

                if (param.Count() > 0)
                {
                    for (int i = 0; i < param.Count(); i++)
                    {
                        cmd.Parameters.Add(param[i]);
                    }
                    cmd.Parameters.Add("@num", "").Direction = ParameterDirection.ReturnValue;

                }
                cmd.ExecuteNonQuery();
                result = (int)cmd.Parameters["@num"].Value;
            }

            return result;
        }
开发者ID:xpengfee,项目名称:Plugin,代码行数:32,代码来源:SqlHelper.cs

示例2: BookCar

        public int BookCar(int carId, string carNumber, DateTime travelDate, bool isLocked, string passengerSSN, string updatedUser)
        {
            string sCommandText = "dbo.[BookCar]";

            try
            {
                DataTable myDataTable = new DataTable();

                // open connection
                mySqlConnection.Open();

                // setup command options and parameteres
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                // add parameter
                SqlParameter[] mySQLParam = new SqlParameter[]{
                    new SqlParameter("@carId", carId),
                    new SqlParameter("@carNumber", carNumber),
                    new SqlParameter("@travelDate", travelDate),
                    new SqlParameter("@isLocked", isLocked),
                    new SqlParameter("@passengerSSN", passengerSSN),
                    new SqlParameter("@updatedUser", updatedUser)
                };

                for (int a = 0; a < mySQLParam.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(mySQLParam[a]);
                }

                int id = Convert.ToInt32(mySqlCommand.ExecuteScalar());

                // close connection
                mySqlConnection.Close();
                return id;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // force close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:51,代码来源:DataAccess.cs

示例3: SaveProfile

        public void SaveProfile(string pRequestorId,
                                string pSalesTeam,
                                string pSegmentCode,
                                string pSegmentAreaCode,
                                string pRole,
                                string pCulture,
                                string pCultureTimeZone,
                                string pProgType,
                                bool pHPSW,
                                string pPartnerName,
                                string pCurrencyCode //14.06 June Release
            )
        {
            string sCommandText = "dbo.[User_Profile_Default_Save]";

            try
            {
                DataTable myDataTable = new DataTable();

                // open connection
                mySqlConnection.Open();

                // setup command options and parameteres
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                // add parameter
                SqlParameter[] mySQLParam = new SqlParameter[]{
                    new SqlParameter("@sRequestorId", pRequestorId),
                    new SqlParameter("@sSalesTeam", pSalesTeam),
                    new SqlParameter("@sSegmentCode", pSegmentCode),
                    new SqlParameter("@sSegmentAreaCode", pSegmentAreaCode),
                    new SqlParameter("@sRole", pRole),
                    new SqlParameter("@sCulture", pCulture),
                    new SqlParameter("@sCultureTimeZone", pCultureTimeZone),
                    new SqlParameter("@sProgType", pProgType),
                    new SqlParameter("@bHPSW", pHPSW),
                    new SqlParameter("@sPartnerName", pPartnerName),
                    new SqlParameter("@sCurrencyCode", pCurrencyCode)
                };

                for (int a = 0; a < mySQLParam.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(mySQLParam[a]);
                }

                mySqlCommand.ExecuteNonQuery();

                // close connection
                mySqlConnection.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // force close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:66,代码来源:DataAccess.cs

示例4: ScalarValue

        // overload to allow parameter arrays
        private string ScalarValue(string sCommandText, SqlParameter[] SqlParameter)
        {
            string s;   // temporary return string container

            try
            {
                // open Connection
                mySqlConnection.Open();

                // configure Command, add Parameter
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                for (int a = 0; a < SqlParameter.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(SqlParameter[a]);
                }

                s = mySqlCommand.ExecuteScalar().ToString();

                // close Connection
                mySqlConnection.Close();

                // return ExecuteScalar value
                return s;
            }
            catch (ApplicationException aex)
            {
                throw aex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // force to close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:46,代码来源:DataAccess.cs

示例5: FillTable

        /// </summary>
        /// Overloaded FillTable method with Array Parameters
        /// <param name="sCommandText">dbo.Object</param>
        /// <param name="SqlParameter">SQL Parameter</param>
        /// <returns>Query result as DataTable</returns>
        private DataTable FillTable(string sCommandText, SqlParameter[] SqlParameter)
        {
            try
            {
                DataTable myDataTable = new DataTable();

                // open connection
                mySqlConnection.Open();

                // setup command options and parameteres
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                for (int a = 0; a < SqlParameter.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(SqlParameter[a]);
                }

                // setup dataAdapater and fill datatTable
                mySqlDataAdapter = new SqlDataAdapter(mySqlCommand);
                mySqlDataAdapter.Fill(myDataTable);

                // close connection

                return myDataTable;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                mySqlConnection.Close();
                // force close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:47,代码来源:DataAccess.cs

示例6: UpdateSlot

        public int UpdateSlot(int bookId, int carId, DateTime travelDate)
        {
            string sCommandText = "dbo.[UpdateSlot]";

            try
            {
                DataTable myDataTable = new DataTable();

                // open connection
                mySqlConnection.Open();

                // setup command options and parameteres
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                // add parameter
                SqlParameter[] mySQLParam = new SqlParameter[]{
                    new SqlParameter("@carBookingId", bookId),
                    new SqlParameter("@carId", carId),
                    new SqlParameter("@travelDate", travelDate)
                };

                for (int a = 0; a < mySQLParam.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(mySQLParam[a]);
                }

                int id = Convert.ToInt32(mySqlCommand.ExecuteScalar());

                // close connection
                mySqlConnection.Close();
                return id;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // force close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:48,代码来源:DataAccess.cs

示例7: ConfirmSlot

        public int ConfirmSlot(int bId, string userName, decimal paidAmount)
        {
            string sCommandText = "dbo.[ConfirmSlot]";

            try
            {
                DataTable myDataTable = new DataTable();

                // open connection
                mySqlConnection.Open();

                // setup command options and parameteres
                mySqlCommand = new SqlCommand();
                mySqlCommand.Connection = mySqlConnection;
                mySqlCommand.CommandText = sCommandText;
                mySqlCommand.CommandType = CommandType.StoredProcedure;

                // add parameter
                SqlParameter[] mySQLParam = new SqlParameter[]{
                    new SqlParameter("@carBookingId", bId),
                    new SqlParameter("@userName", userName),
                    new SqlParameter("@paidAmount", paidAmount)
                };

                for (int a = 0; a < mySQLParam.Count(); a++)
                {
                    mySqlCommand.Parameters.Add(mySQLParam[a]);
                }

                int id = Convert.ToInt32(mySqlCommand.ExecuteScalar());

                // close connection
                mySqlConnection.Close();
                return id;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // force close connection
                if (mySqlConnection.State != ConnectionState.Closed)
                {
                    mySqlConnection.Close();
                }
            }
        }
开发者ID:sadanapraneet,项目名称:travel_agency,代码行数:48,代码来源:DataAccess.cs


注:本文中的System.Data.SqlClient.SqlParameter.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。