Attempting to execute a block of code on a button click to retrieve data from a SQL database. During build, I get the error message
ItemsPage.Button_Clicked(): not all code paths return a value
I tried adding a return statement with a value of the int points but it returned the error
Cannot implicitly convert type int to System.EventHandler
I'm a C# beginner so have little idea on what to do even after attempting to find other solutions online.
public async Task<EventHandler> Button_Clicked()
{
using (MySqlConnection connection = new MySqlConnection("server=localhost;user=app;database=travel_logger;port=3306;password=app"))
{
connection.Open();
var cmd = new MySqlCommand("SELECT points FROM * WHERE email= 20Test@test");
var reader = await cmd.ExecuteReaderAsync();
int points = (int)Convert.ToInt64(reader.GetInt64(0));
return points;
}
}