Mehmet Yilmaz

Mehmet Yilmaz

  • NA
  • 29
  • 2.2k

ABOUT CODE ABBREVIATION

Jul 29 2017 3:22 PM
The following 4 lines of code do not have any problems running, but the code also gives a memory-insufficient error in a 1000-line DataGridView. Will have the same end result I have a SHORT CODE
  

OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + hedef);
connection.Open();

if (fatura1.RowCount > 1) { try { string[] row2 = fatura1.Rows[1].Cells[1].Value.ToString().Split('.'); if (Int16.Parse(row2[1]) == 1) { crow2 = "12/" + (Int16.Parse(row2[2]) - 1); } else if (Int16.Parse(row2[1]) > 1 && Int16.Parse(row2[1]) < 11) { crow2 = "0" + (Int16.Parse(row2[1]) - 1 + "/" + row2[2]); } else if (Int16.Parse(row2[1]) > 11 && Int16.Parse(row2[1]) < 13) { crow2 = (Int16.Parse(row2[1]) - 1 + "/" + row2[2]); } OleDbCommand rowcmd2 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + crow2.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); rowcmd2.ExecuteNonQuery(); string cstdrow2 = row2[1] + "/" + row2[2]; OleDbCommand stdrow2 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + cstdrow2.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); stdrow2.ExecuteNonQuery(); } catch { } }

if (fatura1.RowCount > 2) { try { string[] row3 = fatura1.Rows[2].Cells[1].Value.ToString().Split('.'); if (Int16.Parse(row3[1]) == 1) { crow3 = "12/" + (Int16.Parse(row3[2]) - 1); } else if (Int16.Parse(row3[1]) > 1 && Int16.Parse(row3[1]) < 11) { crow3 = "0" + (Int16.Parse(row3[1]) - 1 + "/" + row3[2]); } else if (Int16.Parse(row3[1]) > 11 && Int16.Parse(row3[1]) < 13) { crow3 = (Int16.Parse(row3[1]) - 1 + "/" + row3[2]); } OleDbCommand rowcmd3 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + crow3.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); rowcmd3.ExecuteNonQuery(); string cstdrow3 = row3[1] + "/" + row3[2]; OleDbCommand stdrow3 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + cstdrow3.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); stdrow3.ExecuteNonQuery(); } catch { } }

if (fatura1.RowCount > 3) { try { string[] row4 = fatura1.Rows[3].Cells[1].Value.ToString().Split('.'); if (Int16.Parse(row4[1]) == 1) { crow4 = "12/" + (Int16.Parse(row4[2]) - 1); } else if (Int16.Parse(row4[1]) > 1 && Int16.Parse(row4[1]) < 11) { crow4 = "0" + (Int16.Parse(row4[1]) - 1 + "/" + row4[2]); } else if (Int16.Parse(row4[1]) > 11 && Int16.Parse(row4[1]) < 13) { crow4 = (Int16.Parse(row4[1]) - 1 + "/" + row4[2]); } OleDbCommand rowcmd4 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + crow4.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); rowcmd4.ExecuteNonQuery(); string cstdrow4 = row4[1] + "/" + row4[2]; OleDbCommand stdrow4 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + cstdrow4.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); stdrow4.ExecuteNonQuery(); } catch { } }

if (fatura1.RowCount > 4) { try { string[] row5 = fatura1.Rows[4].Cells[1].Value.ToString().Split('.'); if (Int16.Parse(row5[1]) == 1) { crow5 = "12/" + (Int16.Parse(row5[2]) - 1); } else if (Int16.Parse(row5[1]) > 1 && Int16.Parse(row5[1]) < 11) { crow5 = "0" + (Int16.Parse(row5[1]) - 1 + "/" + row5[2]); } else if (Int16.Parse(row5[1]) > 11 && Int16.Parse(row5[1]) < 13) { crow5 = (Int16.Parse(row5[1]) - 1 + "/" + row5[2]); } OleDbCommand rowcmd5 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + crow5.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); rowcmd5.ExecuteNonQuery(); string cstdrow5 = row5[1] + "/" + row5[2]; OleDbCommand stdrow5 = new OleDbCommand("Insert Into kdv (a,b,c,d,e,f,g,h) Values ('" + cstdrow5.ToString() + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "','" + null + "')", connection); stdrow5.ExecuteNonQuery(); } catch { } }


Attachment: KDV_SATIR_EKLE.zip

Answers (3)