Solved

Error detected by database DLL

Posted on 2003-11-12
9
1,359 Views
Last Modified: 2011-10-03
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

0
Comment
Question by:shamif
  • 4
  • 3
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9735031
0
 

Author Comment

by:shamif
ID: 9741826
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.  
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9744260
Where are the values for part1, part2, etc set?

mlmcc
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:shamif
ID: 9747636
part1, part2... value are set inside a function. They are all global integer variables.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9752297
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10612462
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
0
 

Author Comment

by:shamif
ID: 10614859
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.
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 10635685
Closed, 125 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question