1
Reply

Check if Date Already Existed

Marvin Retro

Marvin Retro

Oct 10 2017 1:15 PM
196
I have my code here i wish check if the reservation date is already not available
BTW I have a button so after clicking it one time " It said Available " but after clicking it again it will not show anything
 
can someone please help me or correct what if what is wrong with my code
ty for those who are willing help :)
 
DataSet myDataSet = new DataSet();
try
{
connection.Open();
string strAccessSelect = "select count(*) from Borrow where DUEDATE = '" + due3.Text + "' AND BOOK_NUMBER = '" + bno.Text + "'";
OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect, connection);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);
connection.Open();
myDataAdapter.Fill(myDataSet, "Borrow");
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
return;
}
finally
{
connection.Close();
}
DataTable dt = myDataSet.Tables[0];
if (dt != null)
{
if (int.Parse(dt.Rows[0][5].ToString()) > 0)
{
MessageBox.Show(" Not Available");
}
else
{
MessageBox.Show(" Available");
}
}

Answers (1)