c# – 存储过程的架构
发布时间:2020-12-16 00:16:33 所属栏目:百科 来源:网络整理
导读:我有一个程序,我想阅读程序的架构.要检索视图模式,我使用此处显示的查询.同样的方式我想获得存储过程的模式.怎么弄? Plz显示了一些语法. public static DataTable SchemaReader(string tableName){ string sql = string.Format("Select * from {0}",tableNa
我有一个程序,我想阅读程序的架构.要检索视图模式,我使用此处显示的查询.同样的方式我想获得存储过程的模式.怎么弄? Plz显示了一些语法.
public static DataTable SchemaReader(string tableName) { string sql = string.Format("Select * from {0}",tableName); conn.Open(); SqlCommand cmd = new SqlCommand(sql,conn); cmd.CommandType = CommandType.Text; SqlDataReader reader = cmd.ExecuteReader(); DataTable schema = reader.GetSchemaTable(); reader.Close(); conn.Close(); return schema; } 如果有任何查询请问.请提前谢谢. 解决方法
你能做到的
public static DataTable SchemaReader(string tableName) { string sql = "MySP";//replace this with your store procedure name conn.Open(); SqlCommand cmd = new SqlCommand(sql,conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader reader = cmd.ExecuteReader(); DataTable schema = reader.GetSchemaTable(); reader.Close(); conn.Close(); return schema; } 希望这有帮助 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |