Link to home
Start Free TrialLog in
Avatar of andcu
andcu

asked on

Crystal reports

Why do I get an error message of number 20536 which has an error text of, "Unable to connect: incorrect log on parameters.  I use VB 6 nd it only happens in win'95.  It occurs on the line CR.Action = 1 on the following code:

Private Sub cmdPrint_Click()

Dim x As Integer, Ret As Integer

MousePointer = 11

On Error GoTo ErrorHandler

CR.ReportFileName = App.Path & "\ipreport.rpt"

CR.Destination = 1
CommonDialog1.CancelError = True   'If user cancels then it will not continue
CommonDialog1.Flags = cdlPDHidePrintToFile + cdlPDNoSelection + cdlPDNoPageNums + cdlPDUseDevModeCopies
CommonDialog1.ShowPrinter
CR.SelectionFormula = strCR
CR.WindowState = crptMaximized
CR.Action = 1

For x = 0 To 6
    CR.Formulas(x) = ""
Next x

MousePointer = 1

CancelledPrint:

On Error GoTo 0

MousePointer = 1

Exit Sub

ErrorHandler:
 
If Err = 32755 Then
    Resume CancelledPrint
Else
    MousePointer = 1
    Ret = MsgBox("Error " & Err & ":" & " " & Error(Err), vbCritical)
    Exit Sub
End If

MousePointer = 1

End Sub
Avatar of BergJC
BergJC

What type of database are you using? If you are using SQL/ODBC, you must first use the CrystalReport1.Connect method before printing the report.
Here's an example:

CrystalReport1.Connect = "DSN = Marketing;UID = Username;PWD = pass;DSQ = Administration"

**DSN is the server name.
**UID is the name you have been assigned for logging onto the SQL server.
**PWD is the password you have been assigned for logging onto the SQL server.
**DSQ is the database name if your server uses the database concept.
Avatar of andcu

ASKER

The problem is still occuring it is also happening in WinNT but, it wasn't before and as far as I can see I haven't changed anything?!?
What type of database are you using?
skip the 3 commondialog1 lines, and try
Avatar of andcu

ASKER

No, the same error still occurs if I comment out the three lines mentioned above.
Avatar of andcu

ASKER

SQL Server 6.5.
With SQL Server, you must connect to the server first, using either Connect or LogonServer. Almost always, the Connect method works best.
Hi, Andcu: I got the same problem with Crystal report and VB5. Have you fix the problem? If so, Please let me know. Thanks
Avatar of andcu

ASKER

No zli, but I'll let you know if I get to fix it - could you do the same?
Any luck? Andcu. I still cannot figure out yet!
Avatar of andcu

ASKER

zli: Mine seems to work with the connect property set.  Check yours is set and if so, double check your ODBC names i.e. DSN etc. if, of course that's what you're using.

You want a line like:

CR.Connect = "DSN=Helpdesk; UID=sa; PWD=;" (as suggested by BergJC)

Try the above UID and PWD if you are unsure what to use.  The DSN can be found in the ODBC driver details available from the control panel.
So the Connect property did work for you?
Any luck? Andcu. I still cannot figure out yet!
ASKER CERTIFIED SOLUTION
Avatar of BergJC
BergJC

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
Avatar of andcu

ASKER

zli: Post your section of code and I'll see if I have any ideas though I very much doubt it.  Maybe BergJC could have a look too??
Andcu/BergJC: Thanks for your help. I think your suggestions are working for me.