Link to home
Start Free TrialLog in
Avatar of shamif
shamif

asked on

Error detected by database DLL

I created a Crystal Reports 8.5 report and linked a text file using ODBC. Initially after I created the report and I previewed the report and it worked fine. Then I have a visual basic 6.0 program that writes to the text file and prints the report. But when I try to print it gives me an error message. Then afterwards if I try to open the report and try to preview it, it gives me the following errors

ODBC error:[Microsoft][ODBC Text Driver]Too few parameters. Expected 1.

and

Error detected by database DLL.

The error I get on the VB side is:

Run-time error ‘20534’:                            Error detected by database DLL
   
Here is my code

Private Sub cmdPrint_Click()
    On Error GoTo print_click_error
   
    Dim reportline(15) As String * 35
    Dim part(15) As String * 8
    Dim I As Integer
    Dim shift_date As String * 40
    Dim total_parts As String * 40
    Dim part_num0 As String
    Dim part_desc0 As String
    Dim clock_number As String * 80
       
    #Const fDebug = True
    Dim logon As Integer
   
   
    reportline(0) = " 875   RH PEARL WHITE        "
    reportline(1) = "1875  RH GALAXY BLACK     "
    reportline(2) = "1875  RH DEEP WATER         "
    reportline(3) = "1875  RH COOLNESS SILVER "
    reportline(4) = "1875  RH SMOKE GREY        "
    reportline(5) = "1875  RH SAGE MET           "
    reportline(6) = "1875  RH BERRY RED         "
    reportline(7) = "1875   RH SILICA GOLD       "
    reportline(8) = "1875   LH PEARL WHITE        "
    reportline(9) = "1875   LH GALAXY BLACK     "
    reportline(10) = "1875   LH DEEP WATER         "
    reportline(11) = "1875   LH COOLNESS SILVER "
    reportline(12) = "1875   LH SMOKE GREY         "
    reportline(13) = "1875   LH SAGE MET          "
    reportline(14) = "1875   LH BERRY RED        "
    reportline(15) = "1875   LH SILICA GOLD       "
       
    RSet part(0) = part0
    RSet part(1) = part1
    RSet part(2) = part2
    RSet part(3) = part3
    RSet part(4) = part4
    RSet part(5) = part5
    RSet part(6) = part6
    RSet part(7) = part7
    RSet part(8) = part8
    RSet part(9) = part9
    RSet part(10) = part10
    RSet part(11) = part11
    RSet part(12) = part12
    RSet part(13) = part13
    RSet part(14) = part14
    RSet part(15) = part15
   
   
   
    'Print to text file
   
    'shift report and clock report use the same file
    Open PATH_CLOCK_REPORT_TEXT For Output As #1
    shift_date = dtShiftDate.Value
    Print #1, "Shift Date   :  " & shift_date
    Print #1, " "
    clock_number = Trim(Me.txtClockNum)
    Print #1, "Clock Number :  " & clock_number & String(30, " ")
    Print #1, " "
    Print #1, " "
    Print #1, "Customer Part Number" & String(30, " ") & "Quantity "
    Print #1, " "
    For I = 0 To 15
        Print #1, reportline(I), part(I)
    Next I
   
    Print #1, " "
    Print #1, " "
   
    RSet total_parts = "Total Parts:  " & Me.txtTotalParts.Text
    Print #1, total_parts
    Close #1
   
    'print to printer
    With cr1
        .ReportFileName = PATH_CLOCK_REPORT_CRYSTAL
        .Destination = crptToPrinter
        .Action = 1
    End With
    Me.cmdPrint.Enabled = False

print_click_error:
    #If fDebug = True Then
    If Err.Number = 20534 Then
        cr1.Action = 1
    End If
    #End If
    Select Case Err.Number
        Case 0
            Resume Next
        Case 5
            Resume Next
        Case 20
            Resume Next
        Case Else
            strErrLocation = "cmdPrintClick"
            ErrorCheck Err.Number, Err.Description, strErrLocation
    End Select
End Sub

Avatar of Mike McCracken
Mike McCracken

Avatar of shamif

ASKER

I have already looked at crystal decisions web site and the above code includes their suggestion.

If I reboot my computer it work the first or second try. But after that it starts giving me the error. It will also work if I delete the old report and recreate it. But I cannot keep on rebotting or recreating.  
Where are the values for part1, part2, etc set?

mlmcc
Avatar of shamif

ASKER

part1, part2... value are set inside a function. They are all global integer variables.
Are you sure you are getting an error.  You error handling code gets run regardless of whether there is an error or not.

Add an exit sub

    Me.cmdPrint.Enabled = False
    EXIT SUB        '  ADD this line
print_click_error:

mlmcc
Did this get resolved?  If so how?

Unless my final comment solved the problem there is nothing here worthy of a PAQ.
If my comment solved the problem I should be awarded the points.  If i didn't solve it then either post the slution or delete this question.

mlmcc
Avatar of shamif

ASKER

mlmcc,

I couldn't fix the error thats why I had to rewrite the reports. Seting up ODBC connections on client machines wasn't a smart idea either. I rewrote the reports in less time than I spend to fix this problem.
ASKER CERTIFIED SOLUTION
Avatar of Lunchy
Lunchy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial