Beispiel #1
0
        /// <summary>
        /// Command객체에 Parameter를 추가한다.
        /// </summary>
        /// <param name="command"></param>
        /// <param name="param"></param>
        private void AttachParameters(SqlCommand command, ParameterMember param)
        {
            if (param == null)
            {
                return;
            }

            for (int i = 0; i < param.Count; i++)
            {
                SqlParameter cmdPara = new SqlParameter(param.GetName(i), param.GetType(i));
                cmdPara.Value = param.GetValue(i);

                command.Parameters.Add(cmdPara);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Command객체에 Parameter를 추가한다.
        /// </summary>
        /// <param name="command"></param>
        /// <param name="param"></param>
        private void AttachParameters(OleDbCommand command, ParameterMember param)
        {
            if (param == null)
            {
                return;
            }
            for (int i = 0; i < param.Count; i++)
            {
                OleDbParameter cmdPara = new OleDbParameter(param.GetName(i), param.GetType(i));

                cmdPara.Value = param.GetValue(i);

                if (command.CommandType != CommandType.StoredProcedure)
                {
                    command.CommandText = command.CommandText.Replace(param.GetName(i) + " ", "? ");
                }
                else
                {
                    command.CommandText = command.CommandText.Replace(param.GetName(i), "");
                }
                command.Parameters.Add(cmdPara);
            }
            //Console.WriteLine(command.CommandText.ToString());
        }