如何调用一个过程,如果过程没有参数
create proc sp_dropdown as
begin
SELECT r1.regid, r.registration
FROM table1 as r1
INNER JOIN table2 as r ON r1.regid=r.registration and r1.status=r.status
end
回答:
这上面的类是我的SP返回类型,
public class GetAllTableNames_Result {
public string Name { get; set; }
}
,我可以把这个像
public List<GetAllTableNames_Result> GetTableNames() {
List<GetAllTableNames_Result> gatnr = new List<GetAllTableNames_Result>();
SqlCommand cmd = new SqlCommand(
"GetAllTableNames", _connection) {CommandType = CommandType.StoredProcedure};
try
{
_connection.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//do something with data
gatnr.Add(new GetAllTableNames_Result()
{
Name = rdr[0].ToString()
});
}
_connection.Close();
return gatnr;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
finally
{
_connection.Close();
}
}
我相信你可以得到点
以上是 如何调用一个过程,如果过程没有参数 的全部内容, 来源链接: utcz.com/qa/263200.html