private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//MySQLConnectionString
MySQLConnectionString tConnStr = new MySQLConnectionString("localhost", "college", "root", "zcdag", 3306);
MySQLConnection tConn = new MySQLConnection(tConnStr.AsString);
tConn.Open();
try
{
DataSet ds;
ds = new DataSet();
DataSet myds; // 数据集
string str = "selsct *from tongxunlu ;";
MySqlDataAdapter myadp = new MySqlDataAdapter(str, tConn);
//error CS1502: 与“MySql.Data.MySqlClient.MySqlDataAdapter.MySqlDataAdapter(string, MySql.Data.MySqlClient.MySqlConnection)”最匹配的重载////方法具有一些无效参数
///error CS1503: 参数 2: 无法从“MySQLDriverCS.MySQLConnection”转换为“MySql.Data.MySqlClient.MySqlConnection”
myadp.Fill(ds);
bindingSource1.DataSource = myds.Tables["学号"];
myds = new DataSet();
dataGridView1.DataSource = bindingSource1;
}
catch (System.Data.SqlClient.SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
tConn.Close();
}
}
|