在给定分配给其SelectCommand属性的存储过程的名称的情况下,是否有一种从SqlDataSource获取预期参数列表的合理方法?
sgr*_*usa 10
您可以使用SqlCommandBuilder.DeriveParameters方法返回与存储过程关联的参数的信息.迭代集合将允许您确定参数名称,数据类型,方向等.
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection("myConnectionString");
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "myStoredProcName";
cmd.Connection = conn;
conn.Open();
SqlCommandBuilder.DeriveParameters(cmd);
conn.Close();
SqlParameterCollection collection = cmd.Parameters;
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看SqlParameterCollection和SqlParameter类定义.
| 归档时间: |
|
| 查看次数: |
3608 次 |
| 最近记录: |