Solved

Crystal Reports VB6 Logon

Posted on 2014-04-07
8
1,098 Views
Last Modified: 2014-04-08
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.
0
Comment
Question by:triphen
  • 4
  • 4
8 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39984245
Have you tried using the code you say solved your other issue along the same lines?

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28404831.html

mlmcc
0
 

Author Comment

by:triphen
ID: 39984431
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 :/
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 39984554
There is code provided in the other question that should work.  Crystal doesn't use a connection string as such.  

The code is here

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28404831.html#a39977258

mlmcc
0
 

Author Comment

by:triphen
ID: 39984569
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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 39984678
This line

SetReportLocation crxRpt

has to come after you instantiate the report obect

after this line

Set crxRpt = crxApp.OpenReport(App.Path & "\Reports\DetailRecpt.rpt")


mlmcc
0
 

Author Comment

by:triphen
ID: 39984685
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  
---------------------------
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 39984940
That means the connection string is wrong.  You have it set for Integrated Security and the reort probably isn't or the other ay round

mlmcc
0
 

Author Comment

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

This worked!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now