请问在asp.net中不用存储过程怎样执行带参数的查询?

解决方案 »

  1.   

    例子:        SqlConnection Conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction);
            SqlCommand Comm = new SqlCommand("select @bigclassName from bigclass", Conn);
            // 将命令类型设为SQL语句
            Comm.CommandType = CommandType.Text;
            // 添加并给参数赋值
            SqlParameter Parm = Comm.Parameters.Add("@bigclassName", SqlDbType.VarChar, 50);
            Parm.Value = this.tbBigclass.Text;
            Conn.Open();
            Comm.ExecuteNonQuery();
     
            Response.Redirect("articleclass.aspx");
            Conn.Close();