ALTER PROCEDURE pr_topic @subject char(50)  

AS
select * from forum_topic 
where subject=@subject
RETURN请问如何在后台代码中调用该带参数的存储过程请各位大虾指点,谢谢啦最好能两种方法都说说,sqlcommand和sqldataadapter

解决方案 »

  1.   

    这个例子很详细
    http://www.5d.cn/Tutorial/webdevelop/.net/200412/1960.html
      

  2.   

    myCommand = new SqlCommand("pr_topic", myConn);
      myCommand.Parameters.Add(new SqlParameter("@subject", SqlDbType.VarChar, 50));
      myCommand.Parameters["@username"].Value = subject;
      sqldataadapter=new AqlDataAdapter(myCommand);
      

  3.   


    myCommand = new SqlCommand("pr_topic", myConn);
    myCommand.CommandType = CommandType.StoredProcedure;
      myCommand.Parameters.Add(new SqlParameter("@subject", SqlDbType.VarChar, 50));
      myCommand.Parameters["@username"].Value = subject;
      sqldataadapter=new AqlDataAdapter(myCommand);
      

  4.   

    sqlcommand是一个执行数据库的对象.
    sqldataadaptor是一个容器,用来储存sqlcommand执行后返回的数据,以便于datatable,dataset等调用.