I am getting the output that I do not want to get. I think my code is correct however there might be something I missed.
C# Code:
try
{
string mydbConnection = "datasource=localhost;port=3306;username=root;password=Greenford123;";
MySqlConnection connDB = new MySqlConnection(mydbConnection);
MySqlCommand cmdDataBase = new MySqlCommand("SELECT * FROM project.student", connDB);
MySqlDataReader DBReader;
connDB.Open();
DBReader = cmdDataBase.ExecuteReader();
while (DBReader.Read())
{
List<string> mylist = new List<string>();
mylist.Add(DBReader.ToString());
foreach (var item in mylist)
{
MessageBox.Show("The details are " + item);
}
}
connDB.Close();
}
catch(Exception ex)
{
MessageBox.Show("Error! " + ex);
}
What I want to do is store contents from database into a list so that I could do operations on it. Then I want to output the list however the output is not the "string" or data. The output I get is :
OUTPUT: "the details are MySQL.Data.MySqlClient.MySqlDataReader"