csharp,using System.Data;,using System.Data.SqlClient;,,public DataTable ExecuteQuery(string query),{, string connectionString = "your_connection_string";, DataTable dataTable = new DataTable();,, using (SqlConnection connection = new SqlConnection(connectionString)), {, SqlCommand command = new SqlCommand(query, connection);, connection.Open();, SqlDataAdapter adapter = new SqlDataAdapter(command);, adapter.Fill(dataTable);, },, return dataTable;,},
``,,这个函数接受一个SQL查询字符串,执行该查询,并将结果填充到一个DataTable对象中,然后返回该DataTable。Powered By Z-BlogPHP 1.7.3
Copyright Your WebSite.Some Rights Reserved.