当然这些通过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里面,当然也可以直接从数据库读取出来显示。