سلام اساتید و دوستان عزیز
من چند وقتی است برنامه ای نوشتم که کارش به این صورت است هر ماه حدود 70 هزار تا رکورد تحویل بنده می دهند من باید برای انها بارکد پستی تولید کنم با برنامه ای که من الان نوشتم حدود 24 تا 48 ساعت طول میکشه برای 70 هزارتا بارکد درست بشه ، که زمان خیلی زیادی است می خواستم یک راهنمایی کنید کدی که نوشتن طوری تغییر بدم که زمان کمتری طول بکشه .
کدم به این صورت است :
string dbs = textBox2.Text;
string tables = txttable.Text;
string coectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dbs + ";" + "Persist Security Info=False";
OleDbCoection myCoection = new OleDbCoection(coectionString);string query = "select * from " + tables;
OleDbDataAdapter myAdapter = new OleDbDataAdapter(query, myCoection);
DataSet employeeData = new DataSet();
myAdapter.Fill(employeeData);// Repeat for each table in the DataSet's table collection.
foreach (DataTable table in employeeData.Tables)
{
// Repeat for each row in the table.
foreach (DataRow row in table.Rows)
{string num = row["Id"].ToString();
long nume = Convert.ToInt32(num);
string id = row["Id"].ToString();
long ids = Convert.ToInt32(id);
string cod = row["city_cod"].ToString();
string sourcecod = txtsourcecod.Text;
Barcode Test = new Barcode();
Test.SerialNo = ids;
Test.SourceCode = sourcecod;
Test.DestCode = cod;
Test.ServiceType = ParcelServiceType.EMS;
Test.ParcelType = ParcelType.EMS_Letter;
Test.SMSService = false;
Test.TwoReceiptant = true;
Test.ElectronicTwoReceiptant = false;
Test.InsuranceType = InsuranceType.NormalInsurance;
string b;
b = Test.GetBarcode();
string coect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dbs + ";" + "Persist Security Info=False";OleDbCoection OleDbCoection1 = new OleDbCoection(coect);
OleDbCommand OleDbCommand1 = new OleDbCommand();
OleDbCommand1.Coection = OleDbCoection1;
OleDbCommand1.CommandType = CommandType.Text;
//OleDbCommand1.CommandText = "INSERT INTO pasargad (barcod , city , cod , adres , codp , tel , mob , nam , family ) VALUES ('" + b + "','" + city + "','"+cod+"','"+adres+"','"+codp+"','"+tel+"','"+m ob+"','"+nam+"','"+family+"')";
OleDbCommand1.CommandText = "update " + tables + " set barcode='" + b + "' where id=" + ids;
OleDbCoection1.Open();
int result = OleDbCommand1.ExecuteNonQuery();
OleDbCoection1.Close();if (result > 0)
{
OleDbCoection OleDbCoection3 = new OleDbCoection(coect);
OleDbCommand OleDbCommand3 = new OleDbCommand();
OleDbCommand3.CommandType = CommandType.Text;
OleDbCommand3.CommandText = "SELECT * FROM " + tables;
OleDbCommand3.Coection = OleDbCoection1;
OleDbDataAdapter adapter = new OleDbDataAdapter(OleDbCommand3);
DataSet DataSet1 = new DataSet();
adapter.Fill(DataSet1, "'" + tables + "'");
dataGridViewX1.DataSource = DataSet1.Tables["'" + tables + "'"];
}
else
{
MessageBox.Show("Error In Insert");
}}
}
می دونم مشکل اینجاست که یک رکورد یک رکورد می رم جلو ولی اگه میشه راهنمایی کنید کد رو به چه صورت تغییر بدم
- - , .
برچسب:
نویسنده: محمد رضا جوادیان