string myConnectionString;
myConnectionString = "server=localhost;uid=root;pwd=root;database=medicloud;SslMode=None;charset=utf8";
MySqlConnection connection = new MySqlConnection(myConnectionString);
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.Text;
string sqlStr = "Select arm from assign where userId=@name";
cmd.Parameters.AddWithValue("@name", txtValue.Text);
cmd.CommandText = sqlStr;
cmd.Connection = connection;
EncodingProvider ppp;
ppp = CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);
connection.Open();
MySqlDataReader reader = cmd.ExecuteReader();
reader.Read();
string databaseLine = (reader["arm"].ToString());
connection.Close();
# endregion
txtExercise.Text = databaseLine + " (Uncomplete)\n" + databaseLine;
我试图查看数据库中的两行数据。但是,我不知道该怎么看。有人能帮我吗?我试着输入“databaseline”两次,但都看到同一行
如你所见,瑞秋有两种锻炼方式。我想在txtexercise.text查看这两个练习。但是我只能看到第一个,我不能看到第二个。
1条答案
按热度按时间wqsoz72f1#
reader.Read()
将读卡器移到下一行。只调用一次,因此只读取第一行。你可以做一个循环。