缓慢的过程将数据插入到sql数据库 [英] slow process insert data to sql database
问题描述
你好,我心爱的前辈...
我正在使用VB.我有大约6702名员工的记录.
问题是我的应用程序必须处理数据并将其存储到另一个表中,但这需要太多时间.
我正在使用:
1.进度条以查看进度.
2."do while",我正在调用在"do..while"末尾插入数据的过程.
因此,我执行的proc等于员工人数.
这是我的一些代码:
hello my beloved senior...
i''m using VB. i have about 6702 record of employee.
the problem is my application have to process the data and stored it into another table but it takes too much time.
i''m using:
1. progress bar to see the progress.
2. "do while", i''m calling the procedure to insert the data at the end of "do..while"
So i execute the proc equals to the amount of the employee.
here some of my code:
Me.bs.MoveFirst()
' loop-------------------
ProgressBar1.Maximum = Me.bindingsource.Count
Do While x <= Me.dataset.tbdatapegawai.Count
My.Application.DoEvents()
Progress_bar_percent = x / CInt(Me.bindingsource.Count) * 100
Me.persenLabel.Text = Progress_bar_percent.ToString & "%"
'this is only example. the data that has been calculate and ready to be stored
var_1_pajak = 12.000
var_2_bruto = 5.000
var_3_potongan = 2.000
var_4_gasih = 1.500
var_5_potjabatan = 1.725
var_6_iuranpensiun = 900
'saving one data using stored proc (just insert data)
Save_data()
ProgressBar1.Value = x
x = x + 1
Me.bindingsource.MoveNext()
Loop
完成所有数据大约需要18分钟.
有没有办法使它更快?
感谢您的宝贵时间.
对不起我的英语.
问候
Samuel T
it takes about 18 minutes to finish all the data.
is there a way to make it faster?
thanks for your time.
sorry about my english.
regard
Samuel T
推荐答案
,您可以基于对另一个表的选择在表中进行插入.该选择可以包含钙盐.在这种情况下,您的过程可以在几秒钟之内完成一次查询(7k条记录对于数据库来说算不了!)
有关示例,请参见: http://www.sqlteam.com/article/using-select-to -insert-records [^ ]
you can do an insert in a table based on a select from another table. The select can contain calucaltions. In thsi case your process can be done in 1 query in a couple of seconds (7k records is nothing for a database!)
For an example see: http://www.sqlteam.com/article/using-select-to-insert-records[^]
这篇关于缓慢的过程将数据插入到sql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!