我有一个参数'temptbl'(varchar类型)sp'Update_driver_Position',在sp中我选择其他表的数据到'temptbl'。我知道如何在Visual Studio中运行sp,但我不知道如何从'temptbl'(在temptbl中获取日期到sqldatareader)中选择数据。我怎样才能执行一个存储过程,并从视觉工作室的临时表中选择?
这是我如何在SQL Server中运行的SP
Exec dbo.Update_Driver_Position '##Temp'
Select * From ##Temp
这是我的代码在Visual Studio中
using (SqlCommand cmd = new SqlCommand())
{
string text = "Update_driver_Position";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = text;
SqlParameter retval = cmd.Parameters.Add("@Temptbl", SqlDbType.VarChar);
retval.Direction = ParameterDirection.Output;
cmd.Connection = this.GetConnection();
cmd.Connection.Open();
cmd.ExecuteNonQuery();
SqlDataReader reader = (cmd.Parameters["@Temptbl"]);
while (reader.Read())
{
//...
}
}
我知道,我怎么能传递“## temptbl”存储过程事业cmd.Parameters.Add(“@ VENDORNAME”,SqlDbType.VarChar)我们添加参数不是临时表。 – 2011-12-20 16:14:46