日期:2014-05-17 浏览次数:21190 次
server = "localhost";
database = "csharp";
name = "root";
password = "root";
string connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + name + ";" + "PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
string mysql = "select * from books";
MySqlDataAdapter mysqlAdapter = new MySqlDataAdapter(mysql, connection);
DataSet ds = new DataSet();
mysqlAdapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0].DefaultView;
connection.Close();
connection.Dispose();
select * from books
--把*号写成字段名试一试
应该不是Gridview的问题