注册 登录
编程论坛 ASP.NET技术论坛

新手问题

chen1111 发布于 2008-04-20 20:57, 698 次点击
我是新手,看不懂这几个函数的区别及他们的作用,希望哪位高手给我讲解一下,谢了
 public static SqlCommand CreatCmd(string procName, SqlParameter[] prams)
    {
        SqlConnection SqlConn = ReturnConn();
        SqlCommand Cmd = new SqlCommand();
         = CommandType.StoredProcedure;
        Cmd.Connection = SqlConn;
         = procName;
        if (prams != null)
        {
            foreach (SqlParameter paramenter in prams)
            {
                if (paramenter != null)
                {
                    Cmd.Parameters.Add(paramenter);
                }
            }
        }
        return Cmd;
 
    }
    public static SqlCommand CreatCmd(string procName, SqlConnection Conn)
    {
        SqlConnection SqlConn = Conn;
        if (SqlConn.State.Equals(ConnectionState.Closed))
        {
            SqlConn.Open();
        }
        SqlCommand Cmd = new SqlCommand();
         = CommandType.StoredProcedure;
        Cmd.Connection = SqlConn;
         = procName;
        return Cmd;
 
    }
    public static SqlCommand CreatCmd(string procName)
    {
        SqlConnection SqlConn =ReturnConn();
        SqlCommand Cmd = new SqlCommand();
         = CommandType.StoredProcedure;
        Cmd.Connection = SqlConn;
         = procName;
        return Cmd;
0 回复
1