runtime error in application

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bineesh Namboodiri (BineeshNamboodiri_at_discussions.microsoft.com)
Date: 10/27/04


Date: Wed, 27 Oct 2004 02:23:04 -0700

when iam running a process called convert(user-defined)in my application
which is to convert data from excel sheet to sql server table it's giving me
error that "runtime error 2147417851(800010105)
Automation error, server threws an exception". this error is coming only to
one process in my four process . all other are running fine . it's an
application which support data warehousing concepts . the database is
sqlserver 2000 & VB 6.0. This process is to convert data From EXcel file to
a table in sql server which is used for cube creation in further steps.[my
other process takes data from text file only & this process takes data from
excel file].Also this process is working from my source code . but when iam
trying it from exe file of the application it's giving me this error.
  
with this iam attaching a part of my source

Private Function ConvertInvestments(crtbrname)
    Dim oBook As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    Dim objExcel As Excel.Application
    Dim rstInvest As ADODB.Recordset
    Dim writeStr() As Double
    
    Set objExcel = New Excel.Application
    Set oBook = objExcel.Workbooks.Open((APath & "\" & crtbrname &
"\Investment.xls"))
    Set oSheet = oBook.Worksheets(1)
    Set rstInvest = New ADODB.Recordset
    Call InitRecset(rstInvest, "Truncate Table Investment")
    Set rstInvest = Nothing
    Call DeclareRec(rstInvest, "Select * from Investment")
    preProduct = ""
    preCurrency = ""
    For lpVar = 2 To oSheet.Columns.CurrentRegion.Rows.Count
        If Trim(preProduct) <> Trim(oSheet.Range("A" & lpVar).Value) Then
Call getHOProductCode(Trim(oSheet.Range("A" & lpVar).Value),
Trim(oSheet.Range("A" & lpVar).Value), Trim(oSheet.Range("E" & lpVar).Value))
        If Trim(preCurrency) <> Trim(oSheet.Range("F" & lpVar).Value) Then
Call getCurrencyCode(Trim(oSheet.Range("F" & lpVar).Value))
        If HOProductCode <> 0 Then
            rstInvest.AddNew
            rstInvest!ProductCode = HOProductCode
            rstInvest!Description = Left(Trim(oSheet.Range("B" &
lpVar).Value), 30)
            If Trim(oSheet.Range("D" & lpVar).Value) <> "" Then
                rstInvest!InterestRate = oSheet.Range("D" & lpVar).Value * 100
            Else
                rstInvest!InterestRate = 0
            End If
            If IsDate(oSheet.Range("C" & lpVar).Value) = False Then
                rstInvest!MaturityDate = "01/01/1900"
            ElseIf CDate(oSheet.Range("C" & lpVar).Value) <
CDate("01/01/1900") Or CDate(oSheet.Range("C" & lpVar).Value) >
CDate("01/01/2079") Then
                rstInvest!MaturityDate = "01/01/1900"
            Else
                rstInvest!MaturityDate = CDate(oSheet.Range("C" &
lpVar).Value)
            End If
            rstInvest!Amount = (oSheet.Range("E" & lpVar).Value)
            rstInvest!CurrencyCode = CurrencyCode
            rstInvest!CurrencyRate = (oSheet.Range("G" & lpVar).Value)
        End If
    Next lpVar
    If Not rstInvest.EOF Then rstInvest.Update
    oBook.Close
    Set oBook = Nothing
    Set oSheet = Nothing
    objExcel.Quit
    Set objExcel = Nothing
End Function

This part is called when going for conversion process which is also iam
attaching

If chkInvest.Value = vbChecked Then
            If (fs.FileExists(APath & "\" & crtbrname & "\Investment.xls"))
Then
                Call RefreshPrgBar("Investments", crtbrname)
                Call ConvertInvestments(crtbrname)
              
            End If
        End If
It directly converts data in the XLS file to table called investment



Relevant Pages

  • runtime error in the application
    ... when iam running a process called convertin my application ... which is to convert data from excel sheet to sql server table it's giving me ... This process is to convert data From EXcel file to ... Dim oSheet As Excel.Worksheet ...
    (microsoft.public.vb.bugs)
  • runtime error in my application
    ... when iam running a process called convertin my application ... which is to convert data from excel sheet to sql server table it's giving me ... This process is to convert data From EXcel file to ... Dim oSheet As Excel.Worksheet ...
    (microsoft.public.vb.bugs)
  • Re: call a function using ado
    ... i was in a hurry so i copied the function from the excel ... ' Make a connection to the sttr sql server ... Dim oConn As ADODB.Connection ... Dim cmdCommand As ADODB.Command ...
    (microsoft.public.data.oledb)
  • Re: Text file import is dropping records
    ... Excel and Access behaves a little differently than of SQL Server. ... Server is doing is combine your data until the fixed number of character are ... Dim objFileSystem ...
    (microsoft.public.sqlserver.dts)
  • Re: import Excel worksheet to SQL Server table
    ... that this can't be done b/w Excel and SQL Server. ... concatenate a string, but when you pass that string to a SQL Server table, ... reopened the excel file and started to run my app. ... Dim con As New ADODB.Connection ...
    (microsoft.public.excel.programming)