manilike mani

manilike mani

  • NA
  • 2
  • 1.4k

i am try to update string into integer from database

Oct 5 2015 2:26 AM
char[] section = new char[6];
section[0] = '0';
section[1] = 'A';
section[2] = 'B';
section[3] = 'C';
section[4] = 'D';
section[5] = 'E';
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
int a;
try
{
a = int.Parse(dataGridView1.Rows[i].Cells["dgvcsection"].Value.ToString());
}
catch
{
a = 0;
}
for (int j = 0; j <= a; j++)
{
//Data.InitConnection();
char b = section[j];
SqlCommand cmd = new SqlCommand("SPClass", Data.connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ClassID", 0);
cmd.Parameters.AddWithValue("Standard", dataGridView1.Rows[i].Cells["dgvcstandard"].Value.ToString());
cmd.Parameters.AddWithValue("Section", b.ToString());
cmd.Parameters.AddWithValue("pindex", i + 1);
cmd.Parameters.AddWithValue("cindex", j);
cmd.Parameters.AddWithValue("Batch", textBox1.Text);
cmd.Parameters.AddWithValue("@created_ by", Mashupdata.EmployeeID);
cmd.Parameters.AddWithValue("@created_date", "0");
cmd.Parameters.AddWithValue("@modified_by", Mashupdata.EmployeeID);
cmd.Parameters.AddWithValue("@modified_date", "0");
cmd.Parameters.AddWithValue("@ext", "0");
cmd.ExecuteNonQuery();
MessageBox.Show("class allotted successfully");
}
}
} Data.CloseConnection();
}
catch(Exception ex)
{
Utility.ErrorLog.WriteToFile(Mashupdata.errorFile, "FrmClassAllotment:button1_Click", ex.Message);
}

Answers (1)