我想要两列的结果,而不仅仅是一列。我试过了:
MessageBox.Show(reader.GetString("traceid", "idref"));
但它不起作用。我是C#的初学者,有人可以帮忙吗?
String str = @"server=localhost;database=asianimport;userid=tera;password=******;";
MySqlConnection con = null;
try
{
con = new MySqlConnection(str);
con.Open(); //open the connection
MessageBox.Show("connect " );
String cmdText = "SELECT * FROM tracerecord limit 3";
MySqlCommand cmd = new MySqlCommand(cmdText, con);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
MessageBox.Show(reader.GetString("traceid", "idref"));
}
}