【发布时间】:2014-11-04 21:53:45
【问题描述】:
例如,如果我在 mysql 数据库中有这个表
table: people
id fname lname age profession
1 Gordon Batonvere 32 Teacher
2 Baron Greenstick 45 Engineer
. . .
并且在表单上使用这点mysql,我可以得到结果:
private void viewFormOne_Load(object sender, EventArgs e)
{
string conn = "server=localhost;database=dbname;user=username;password=password;";
MySqlConnection myconn = new MySqlConnection(conn);
string sql = "SELECT * FROM `people`";
MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn);
DataTable dt = new DataTable();
try
{
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (dt.Rows.Count == 0)
{
MessageBox.Show("Sorry, there are no records to show.", "No Records");
}
else
{
//What to do here is what I don't know how to go about
}
}
如何在这样的表单上显示该数据:
NAME: Gordon Batonvere
AGE: 32
------------------------
| DISPLAY FULL PROFILE | //This is a button
------------------------
.. .. And so on
如何让标签和按钮动态显示?
【问题讨论】:
标签: c# mysql winforms compact-framework