Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
  string sql1 = @"Select * from Meeting where meeting_id = {0}";
    DataTable dt = DBUtl.GetTable(sql1, TxtMeetingID.Text);
    if (dt.Rows.Count == 1)
    {
        //populate the form = retrieve value from DataTable
        TxtDate.Text = String.Format("{0:yyyy-MM-dd}", dt.Rows[0]["date"]);
        DrpRoom.SelectedValue = dt.Rows[0]["room_id"].ToString();
        DrpPax.SelectedValue = dt.Rows[0]["attendees_pax"].ToString();
        ti.Value = dt.Rows[0]["start_time"].ToString();
        to.Value = dt.Rows[0]["end_time"].ToString();
    }
    else
    {
        LtlMsg.Text = "Meeting ID not found – please try again.";
    }
}



> The error i got was Format exception error unhandled by user
An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code
Additional information: Input string was not in a correct format.


> how do i populate/retrieve date without converting to string? because i still need to do a delete query to delete the booking.
> Please help me!

What I have tried:

I tried to convert it to datetime and then string it .. But it got red underline.
Posted
Updated 26-Jan-18 7:29am
v2
Comments
A_Griffin 27-Jan-18 3:21am    
Try to isolate the line where the problem is. And why does your having to do a delete operation mean you can't convert the date to a string (or even retrieve it as one form the database to begin with, using MySQL's date_format function)?
dibdab 27-Jan-18 9:22am    
I actually solved it! Thank you
A_Griffin 27-Jan-18 9:25am    
Well done!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900