自动生成数据库字典(sql2008)

发表于:2014-10-08 10:38

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:飘渺の云海    来源:51Testing软件测试网采编

  当然这些通过PRING出来的代码使用传统的方式是调用不到的,通过查找资料,终于在国外一个XXX网站找到了解决方案。
private static string message = "";
public static string ExecuteNonQuery(string connextionString, CommandType commandType, string commandText, bool outputMsg)
{
if (connextionString == null || connextionString.Length == 0) throw new ArgumentNullException("connectionString");
// Create & open a SqlConnection, and dispose of it after we are done
using (SqlConnection connection = new SqlConnection(connextionString))
{
message = "";
connection.Open();
connection.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs e)
{
message += "\n" + e.Message;
};
// Call the overload that takes a connection in place of the connection string
if (connection == null) throw new ArgumentNullException("connection");
// Create a command and prepare it for execution
SqlCommand cmd = new SqlCommand(commandText, connection); ;
cmd.CommandType = commandType;
// Finally, execute the command
int retval = cmd.ExecuteNonQuery();
// Detach the SqlParameters from the command object, so they can be used again
cmd.Parameters.Clear();
connection.Close();
return message;
}
}
  调用就不用写了嘛。一切就这么简单,生成的是一份标准的htm代码,可直接放到HTML里面,当然也可以直接从数据库读取出来显示。
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号