I have a datagridview with columns,Book no,Book Name,Issue Date,Return Date,remarks.
i have set the issuedate and returndate format as "d"(ie,dd/MM/yyyy) and issue date cell value as datetime.now.
when i am inserting the values it is giving a conversion error.My sqlserver issuedate and returndate columns are of datetime datatypes
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
when i try to insert issuedate as follows it is working
but when i am trying to fetch the value from datagridview cell for insert it is giving the above error
my code is ;
LibraryLib.Library obj = new LibraryLib.Library();
string bookno, remarks ;
DateTime issuedt, returndt;
for (i = 0; i < (dataGridView1.Rows.Count - 1); i++)
dgr = dataGridView1.Rows[i];
bookno = dgr.Cells.Value.ToString();
issuedt = DateTime.Parse(dgr.Cells.Value.ToString());
//issuedt= DateTime.Now.ToString("MM/dd/yyyy"); this is working
returndt = DateTime.Parse(dgr.Cells.Value.ToString());
remarks = dgr.Cells.Value.ToString();
obj.idu("insert into bookissue values(" + t1.Text.ToString() + ",'" + bookno + "','" + issuedt + "','" + returndt + "','" + remarks + "')");
pls help me get out of this situation as i am new to c#.net
thanks in advance