VB 4.0, Crystal Reports and Access via ODBC 
Author Message
 VB 4.0, Crystal Reports and Access via ODBC

Quote:

>         I am trying to invoke a Crystal Report from VB 4.0. The report
> reads data from an Access database using an ODBC driver. I have tried to
> do this in a number of different ways and I always get the same response,
> Error number 536 "Incorrect log on parameters".

>         Does anyone out there know how to print a report under these
> circumstances? Alternatively is there anyway I could find out more about
> the "incorrect parameters"?

Hi James,

you don't state if you want to use the report control or the pe-engine.
Anyhow, here are both:

The CR control:
    CrwReport.Connect = "DSN="
    CrwReport.Connect = CrwReport.Connect & Trim$(Server) & ";"
    CrwReport.Connect = CrwReport.Connect & "UID=" & Trim$(dbuserid) &
";"
    CrwReport.Connect = CrwReport.Connect & "PWD=" & Trim$(dbpassword) &
";"
    CrwReport.Connect = CrwReport.Connect & "DSQ=" & Trim$(dbname)

The PE-Engine:
    Dim hJob As Integer
    Dim rc As Integer
    Dim DbLoginInfo As PELogOnInfo

'    PEOpenEngine is done in form_load() or main sub.
    hJob = PEOpenPrintJob(RepName)

    rc = PEOutputToPrinter(hJob, 1)

    DbLoginInfo.StructSize = PE_SIZEOF_LOGON_INFO
    DbLoginInfo.ServerName = Server & Chr$(0)
    DbLoginInfo.DatabaseName = dbname & Chr$(0)
    DbLoginInfo.UserID = dbuserid & Chr$(0)
    DbLoginInfo.PassWord = dbpassword & Chr$(0)

    rc = PESetNthTableLogOnInfo(hJob, 0, DbLoginInfo, 1)
    rc = PEStartPrintJob(hJob, True)
    If (rc = 0) Then
        ' didn't succeed opening the window
        rc = PEGetErrorCode(hJob)
        If rc <> 0 Then
            ' If there is an error code, find out what it means
            Dim Errortext As String
            Dim TextHandle As Integer, TextLength As Integer, ErrNum As
Integer
            ErrNum = PEGetErrorText(hJob, TextHandle, TextLength)
            If rc = 0 Then
                ' If getting the text failed, say so
                Errortext = "Error in ErrorTrap routine"
            Else
                ' Get the text from the handle
                Errortext = String$(TextLength, 0)
                rc = PEGetHandleString(TextHandle, Errortext,
TextLength)
                Errortext = Trim$(Errortext)
                Errortext = Left$(Errortext, Len(Errortext) - 1)
            End If
        MsgBox "Error #" & ErrNum & vbCrLf & Errortext
        End If
    End If
    DoEvents
    While (PEGetWindowHandle(hJob) <> 0)
        DoEvents
    Wend
    PEClosePrintJob hJob
'    PECloseEngine is done in EndProgram()

--

  Regards,


  Product Developer
  ATEX Media Solutions Development AS,
  http://www.*-*-*.com/




Sun, 05 Mar 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VB 4.0, Crystal Reports and Access via ODBC

2. VB 4.0, Crystal Reports and Access via ODBC

3. Crystal Reports - Access Database via ODBC - Patternmatching

4. VB 4.0 Database Access via ODBC

5. REPORTS and VB 4.0: Access or Crystal??

6. VB 4.0 & Access 7.0 Crystal Reports

7. VB 3.0 + Access 2.0 + Crystal Reports 4.0

8. Crystal Report - VB 4.0/16 - Access

9. Crystal Reports VBX 4.0 - ODBC

10. Oracle Date fields via ODBC in Crystal Reports

11. Crystal Reports bug when connecting via ODBC to 2 different datasources

12. Can crystal report access MS Access ODBC driver in Window NT server

 

 
Powered by phpBB® Forum Software