command = new SqlCommand("SELECT [Id] FROM [Recent] WHERE [LibraryId] = @LibraryId", sqlConnection);
byte _id = 0;
command.Parameters.AddWithValue("LibraryId", library);
SqlDataReader sqlReader = null;
try
{
sqlReader = await command.ExecuteReaderAsync();
while (await sqlReader.ReadAsync())
{
title = Convert.ToString(sqlReader["Id"]);
}
}
catch (Exception exc)
{
Console.WriteLine(exc.Message + " " + exc.Source);
_id = 0;
}
finally
{
if (sqlReader != null)
sqlReader.Close();
if (_id != 0)
{
command = new SqlCommand("DELETE FROM [Recent] WHERE [Id] = @Id", sqlConnection);
command.Parameters.AddWithValue("Id", _id);
await command.ExecuteNonQueryAsync();
}
}
command = new SqlCommand("SELECT [Id] FROM [Recent] WHERE [LibraryId] = @LibraryId", sqlConnection);
byte _id = 0;
command.Parameters.AddWithValue("LibraryId", library);
try
{
_id = Convert.ToByte(command.ExecuteScalar());
}
catch (Exception exc)
{
Console.WriteLine(exc.Message + " " + exc.Source);
_id = 0;
}
finally
{
if (_id != 0)
{
command = new SqlCommand("DELETE FROM [Recent] WHERE [Id] = @Id", sqlConnection);
command.Parameters.AddWithValue("Id", _id);
await command.ExecuteNonQueryAsync();
}
}
{
toolStrip1.Focus();
}