我尝试了几次使它工作,但它只是没有用
mysql数据填充datagridview,这是我的代码:
string connectionString = "SERVER=localhost;DATABASE=shootsource;UID=root;PASSWORD=;";
string sql = "SELECT * FROM characters";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
sCommand = new MySqlCommand(sql, connection);
sAdapter = new MySqlDataAdapter(sCommand);
sBuilder = new MySqlCommandBuilder(sAdapter);
sDs = new DataSet();
sAdapter.Fill(sDs, "characters");
sTable = sDs.Tables["characters"];
connection.Close();
dataGridView1.DataSource = sDs.Tables["characters"];
dataGridView1.ReadOnly = true;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
它只显示mysql表’characters’中的列:id,name,time等…我如何从db填充它?
这是问题的图像: