When I execute the application, the application runs... then when I click the button I'm getting the error
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
I'm not sure how to go about fixing this, as most of the solutions on the internet don't seem to work for me. Is this something that is on the SQL side?
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcn1 = new SqlConnection("My Connection String");
sqlcn1.Open();
//Stored Procedure
SqlCommand sqlcmddel = new SqlCommand("My_Stored_Procedure", sqlcn1);
sqlcmddel.CommandType = CommandType.StoredProcedure;
sqlcmddel.ExecuteNonQuery();
sqlcn1 = new SqlConnection("My Connection String");
sqlcn1.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
SqlCommand sqlcmdins = new SqlCommand("My_Stored_Procedure", sqlcn1);
sqlcmdins.CommandType = CommandType.StoredProcedure;
//Stored Procedure
sqlcmdins.Parameters.Add("@sugnum", SqlDbType.Int).Value = Convert.ToInt64 (row.Cells[0].Value);
sqlcmdins.Parameters.Add("@sugtype", SqlDbType.NVarChar, 50).Value = Convert.ToString(row.Cells[1].Value);
sqlcmdins.Parameters.Add("@buyerid", SqlDbType.NVarChar, 50).Value = Convert.ToString (row.Cells[2].Value);
sqlcmdins.Parameters.Add("@duedate", SqlDbType.DateTime).Value = Convert.ToDateTime (row.Cells[3].Value);
sqlcmdins.Parameters.Add("@xrelqty", SqlDbType.Float).Value = Convert.ToDouble (row.Cells[4].Value);
sqlcmdins.Parameters.Add("@purchasingfactor", SqlDbType.Float).Value = Convert.ToDouble (row.Cells[5].Value);
}
}