Hi to all,
Iam using vb6.0,excel 2003 and access , by vb6.0 iam retrieve the data from excel and store it in the msaccess 2003.
the problem is i need to upload about 20000 or above it take about 10 min and more.User asking me to reduce the time .
can any one help me in this...,
here is my code........... ............... ............
Private Sub cmdExcelupload_ Click()
On Error GoTo ERRORHANDLER
Dim xlApp As Excel.Applicati on
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim path
Dim intI As Integer
cdFiles.Filter = "Only Excel files (*.xls)|*.xls"
cdFiles.ShowOpe n
path = cdFiles.FileNam e
If Len(cdFiles.Fil eName) = 0 Then
cmdExcelupload. Enabled = False
optExcel.Value = False
Exit Sub
End If
Set xlApp = New Excel.Applicati on
Set xlbook = xlApp.Workbooks .Open(path)
Set xlsheet = xlApp.Worksheet s("sheet1")
'Processing label box
lblProcessing.V isible = True
ssDebitcardInfo rmation.Enabled = False
intI = 2
Do Until xlsheet.Cells(i ntI, 1) = ""
strSql = "Insert into InputExcelData values ("
strSql = strSql & "'" & intI - 1 & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 1) & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 2) & "' ,"
strSql = strSql & "#" & xlsheet.Cells(i ntI, 3) & "# ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 4) & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 5) & "' ,"
strSql = strSql & "#" & xlsheet.Cells(i ntI, 6) & "# ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 7) & "' ,"
Set rs = objCon.Execute( strSql)
intI = intI + 1
Debug.Print intI
Loop
xlbook.Close
Set xlApp = Nothing
ERRORHANDLER:
If Err.Number <> 0 Then
If Err.Number = 9 Then
MsgBox "", vbCritical
Else
Call err1
End If
'
End If
End Sub
Iam using vb6.0,excel 2003 and access , by vb6.0 iam retrieve the data from excel and store it in the msaccess 2003.
the problem is i need to upload about 20000 or above it take about 10 min and more.User asking me to reduce the time .
can any one help me in this...,
here is my code........... ............... ............
Private Sub cmdExcelupload_ Click()
On Error GoTo ERRORHANDLER
Dim xlApp As Excel.Applicati on
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim path
Dim intI As Integer
cdFiles.Filter = "Only Excel files (*.xls)|*.xls"
cdFiles.ShowOpe n
path = cdFiles.FileNam e
If Len(cdFiles.Fil eName) = 0 Then
cmdExcelupload. Enabled = False
optExcel.Value = False
Exit Sub
End If
Set xlApp = New Excel.Applicati on
Set xlbook = xlApp.Workbooks .Open(path)
Set xlsheet = xlApp.Worksheet s("sheet1")
'Processing label box
lblProcessing.V isible = True
ssDebitcardInfo rmation.Enabled = False
intI = 2
Do Until xlsheet.Cells(i ntI, 1) = ""
strSql = "Insert into InputExcelData values ("
strSql = strSql & "'" & intI - 1 & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 1) & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 2) & "' ,"
strSql = strSql & "#" & xlsheet.Cells(i ntI, 3) & "# ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 4) & "' ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 5) & "' ,"
strSql = strSql & "#" & xlsheet.Cells(i ntI, 6) & "# ,"
strSql = strSql & "'" & xlsheet.Cells(i ntI, 7) & "' ,"
Set rs = objCon.Execute( strSql)
intI = intI + 1
Debug.Print intI
Loop
xlbook.Close
Set xlApp = Nothing
ERRORHANDLER:
If Err.Number <> 0 Then
If Err.Number = 9 Then
MsgBox "", vbCritical
Else
Call err1
End If
'
End If
End Sub
Comment