Click here to Skip to main content
15,887,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all how to solve this error:
Value of '01/01/0001 12:00:00 AM is not valid for 'value'.'Value'Should be between 'MinDate'and 'MaxDate'.<br />
Parameter name:Value 
?

C#
private void Find()
        {
            BOEmployee oBOEmployee = new BOEmployee();
            DataTable dt = oBOEmployee.List_Find(txtEName.Text.Trim());
            if (dt.Rows.Count > 0)
            {
                BindEmployeeData(dt);
            }
            else
            {
                MessageBox.Show("No Record Found");
                

                Search oSearch = new Search();

                oSearch.strSQL = "buson_getEmployee_innerjoin";
                oSearch.Text = "List of Items";
                oSearch.ShowDialog();

                if (oSearch.sChoose)
                {
                    
txtEID.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["EmpId"].Value.ToString();
txtEName.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["EmpName"].Value.ToString();
cbPosition.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["Position"].Value.ToString();
cbDepartment.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["Department"].Value.ToString();
cbBranch.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["Branch"].Value.ToString();
cmbSalary.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["SalaryStructure"].Value.ToString();
                    if (oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["Status"].Value.ToString() == "Deactive")
                    {
                        cbActive.Checked = false;
                        RelivingDate.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["RelivingDate"].Value.ToString();
                       
                    }
                    else
                    {
                        cbActive.Checked = true;
                        RelivingDate.Text = "01/01/0001 12:00:00 AM";
                        
                    }
                    txtPhone.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["phone"].Value.ToString();
                    txtMailId.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["MailId"].Value.ToString();
                    txtAddress.Text = oSearch.dgvfind.Rows[oSearch.sChooseRow].Cells["Address"].Value.ToString();
                  
                }
            }
Posted
Updated 4-Mar-13 2:09am
v3

1 solution

This line:
C#
RelivingDate.Text = "01/01/0001 12:00:00 AM";

replace with:
C#
RelivingDate.Text = "01/01/1890 12:00:00 AM";

or any which is in range of Date and Time[^] for specific data type.
 
Share this answer
 
Comments
DhananjayanP 4-Mar-13 8:24am    
Thank's now working fine
Maciej Los 4-Mar-13 8:32am    
You're welcome ;)
It would be nice to know that my solution was helpful...
fjdiewornncalwe 4-Mar-13 13:17pm    
I would suggest that RelivingDate.Text = DateTime.MinValue.ToString("MM/dd/yyyy hh:mm tt"); rather than a hard-coded value.
(+5, BTW)
Maciej Los 4-Mar-13 13:27pm    
Good suggestion. Thank you!
Using date "1890-01-01" is symbolic, means: zero. That's force of habit ;)

Thank you, Marcus ;)

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