以SQL命令方式调用存储过程
string str = "Data Source=.;Initial Catalog=***;Integrated Security=True"; using (SqlConnection conn = new SqlConnection(str)) { string sql = @"DECLARE @PCOUNT INT,@TCOUTN INT,@ReturnVal INT; EXEC @ReturnVal = [proc_LogList] 'admin','删除',1,12,@TCOUTN OUTPUT,@PCOUNT OUTPUT; SELECT @ReturnVal,@TCOUTN,@PCOUNT"; SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); sdr.NextResult(); if (sdr.Read()) { Console.WriteLine(sdr[1]); } sdr.Close(); sdr.Dispose(); }
DATASET接收或datareader接收都可。