C#代码:
command = new SqlCommand(null, connection);
command = createSQLQuery(command); // returns a valid SQL Query that returns results in SQL Management Studio 2012
//dataGridView1.DataSource = GetData(command);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
connection.Close();
dataGridView1.DataSource = GetData(command);
debugMySQL();
public DataTable GetData(SqlCommand cmd) {
//SqlConnection con = new SqlConnection(connString);
//SqlCommand cmd = new SqlCommand(sqlcmdString, cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
connection.Open();
DataTable dt = new DataTable();
da.Fill(dt);
connection.Close();
return dt;
}
我正在使用 C# 和 WinForm 并使用 Visual Studio 2012 进行开发。