Link to home
Start Free TrialLog in
Avatar of triphen
triphen

asked on

Crystal Reports VB6 Logon

Hello Experts,

I am trying to run a Crystal Report thorugh VB6. Here is my code:

Dim crxApp As CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report


    Set crxApp = New CRAXDRT.Application
    Set crxRpt = crxApp.OpenReport(App.Path & "\Reports\DetailRecpt.rpt")
    crxRpt.ParameterFields(1).AddCurrentValue ("44444") 'testing with trans# 44444


CRViewer.ReportSource = crxRpt
CRViewer.ViewReport

Open in new window


It generates this error:

---------------------------
Crystal Report Viewer
---------------------------
Logon failed.
Details: 28000:[Sybase][ODBC Driver][SQL Anywhere]Invalid user ID or password [Database Vendor Code: -103 ]
---------------------------
OK  
---------------------------


I don't have any login info within my VB code as you can see. I cant seem to figure out the syntax for the connection string. I have successfully used this connection string in the past to connect.

"Driver={SQL Anywhere 10};Password=password;Persist Security Info=True;User ID=user;Data Source=sqlbase;Location=sqlbase"


Any help would be appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

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 triphen
triphen

ASKER

m1mcc,

Thanks for your response. The solution I accepted there worked but when I moved the EXE out of my development environment it not generates that logon error. I am sure it's because I dont have any connection string in my code, however I dont know the syntax :/
SOLUTION
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 triphen

ASKER

Private Sub SetReportLocation(ByRef RepObj As CRAXDRT.Report)

    Dim CrxDDF As CRAXDRT.DatabaseTable
    Dim CP As CRAXDRT.ConnectionProperties

    For Each CrxDDF In RepObj.Database.Tables
        Set CP = CrxDDF.ConnectionProperties
        CP.DeleteAll
        CP.Add "Connection String", "Driver={SQL Anywhere 10};Password=password;Persist Security Info=True;User ID=user;Data Source=sqlbase;Location=sqlbase"
    Next

    Set CrxDDF = Nothing
    Set CP = Nothing

End Sub




Private Sub Form_Load()

Dim crxApp As CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report

 SetReportLocation crxRpt


    Set crxApp = New CRAXDRT.Application
    Set crxRpt = crxApp.OpenReport(App.Path & "\Reports\DetailRecpt.rpt")
    crxRpt.ParameterFields(1).AddCurrentValue ("44444") 'testing with trans# 44444


CRViewer.ReportSource = crxRpt
CRViewer.ViewReport


End Sub

Open in new window



Generates:

RunTime error 91

Object variable or With Block variable not set
SOLUTION
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 triphen

ASKER

Looks better, different error

---------------------------
Crystal Report Viewer
---------------------------
Logon failed.
Details: 28000:[Sybase][ODBC Driver][SQL Anywhere]Login mode 'Integrated' not permitted by login_mode setting [Database Vendor Code: -1074 ]
---------------------------
OK  
---------------------------
SOLUTION
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 triphen

ASKER

CP.Add "ConnectionString", "Driver={SQL Anywhere 10};Uid=user;Pwd=password;DSN=sqlbase;"

This worked!