for (int a = 0; a < dataGridView1.Rows.Count - 1; a++)
{
string item11 = dataGridView1[0, a].Value.ToString();
string broktype11 = dataGridView1[1, a].Value.ToString();
string brokrate11 = dataGridView1[2, a].Value.ToString();
string tranrate = dataGridView1[3, a].Value.ToString();
string trantype11 = dataGridView1[4, a].Value.ToString();
DateTime t = Convert.ToDateTime(dataGridView1[5, a].Value.ToString());
string z = t.Date.ToString("dd/mm/yyyy");
string martype11 = dataGridView1[6, a].Value.ToString();
string marrate11 = dataGridView1[7, a].Value.ToString();
SqlCommand cmd1 = new SqlCommand("select AC_code from accountm where name ='" + dataGridView1[8, a].Value.ToString() + "'and compcode='" + Compcls.Gcomp_cd + "' ", con);
string ACcode = Convert.ToString(cmd.ExecuteScalar());
cmd.CommandText = ("insert into PITBROK (COMPCODE,ITEMCODE, BROKTYPE,BROKRATE,TRANRATE,TranType,uptostdt,MARTYPE,MARRATE,AC_CODE) values('" + Compcls.Gcomp_cd + "','" + item11 + "','" +broktype11 + "','"+brokrate11+"','"+tranrate+"','"+trantype11+"','"+z.Trim()+"','"+martype11+"','"+marrate11+"','"+ACcode+"') ");
cmd.ExecuteNonQuery();
MessageBox.Show("done");
error=The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.