Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing Crystal Reports (8) within VB 3

Status
Not open for further replies.

marabou

IS-IT--Management
Jan 12, 2001
86
GB
I have a hugely urgent problem

I have written about fifteen different reports, using version 8, which need to be viewed within from a VB program. I am having terrible trouble getting the reports to connect and show the parameter dialog box(the one which gives both discrete and multiple value options for the end user). I think it is a version thing as I never had this problem before the release of version 8.

Firstly, could I check which controls I should be using for calling the reports from within vb 6? Should I be using this web viewer thing, or have I got another option?

Secondly, at the minute I am using the Crystal Report control and for some reason it displays a parameter box for one report and then terminates and for another one it doesn't do anything at all.

I am in desperate need of some help. Could anyone point me to whatever I seemed to have missed?

Thanks in advance
 
Are you using dictionaries? We had a problem using them with VB 6. We had to re-write all reports without dictionaries. The program was blowing up for no apparent reason.
 
No I'm not, its really strange, as there seems to be no correlation as to the ones which are working and the ones which are not. I'm still no further with the problem, I hope somebody can help.
 
I now have a different problem. I am using Oracle 8i as my database and I'm not sure of the code to open the Database. I keep getting the error message

Server has not yet been opened

I hope somebody can help me.

Thanks in advance
 
I've got a similar problem, with VB6, Oracle8i, and Crystal Reports 8.

I've tried to connect to the database using the following:

report.Database.SetDataSource "Provider=OraOLEDB.Oracle.1;Password=MyPassword;Persist Security Info=True;User ID=MyUsername;Data Source=MyServer",

which got rid of the Server has not yet been opened message, and tried to log on to the server using the following:

report.Database.LogOnServerEx "p2sodbc.dll", "myServer", "myDatabaseName", "myUsername", "myPassword", "Oracle8i", "Provider=OraOLEDB.Oracle.1;Password=MyPassword;Persist Security Info=True;User ID=MyUsername;Data Source=MyServer"

I realise this repeats most of the information, but I can't see any other way of doing it. Can anyone provide any example code that uses LogOnServerEx, as the help files are as useful as an inflatable knife-sharpener.

Thanks,
DynamicArray
 
Oops, forgot to add the error that was produced by the previous code!

Run-time eror '-2147192179 (8004728d)';
Error detected by database DLL.

I'm not sure if I've got the right dll, but I've tried using odbc32.dll, and that gives an error message that says it can't find odbc3d.dll (I can't find it on my system).

Thanks,
DynamicArray
 
A) You have to pass the correct number of parameters to .LogonServer. You cannot simply pass any number of parameters that you wish.

b) You use .SetDataSource if you have created your Crystal Report with ADO as the data source and applied a SQL statement to create the report. Then, in VB, you open the SQL statement and send the recordset to the report. If you did not do this, then do not use it.

If you're using ODBC with a DSN:

.LogonServer "p2sodbc.dll", "DSN Name",, "user", "password"

The DSN name is case sensitive.

If you're not using a DSN, but passing the server name and database name, people have more luck with .SetLogonInfo.

.Database.Tables(1).SetLogonInfo "server", "database", "user", "password"
 
Hi,
Thanks for the suggestions, unfortunately I'm still getting errors.

Using the .LogonServer method, an error message opens that says 'Server has not yet been opened'.

Using the .SetLoginInfo method, I can enter Crystal parameter values (sounds more hopeful), but when I continue from that screen, it pops up an info box that again says 'Server has not yet been opened'.

Is there anything I'm missing?

Thanks,
DynamicArray
 
marabou,

There are four integration methods for launch ing reports from VB. Each has it's own syntax and strengths and weaknesses. Then there is the 'web thingy'. Your first task is to decide which to use. They are listed in the FAQ on "what to include in your question". There is a comparison of the features of each on Crystal Decisions web site.

DynamicArray,

It appears that you have selected an integration method, but I am not sure what it is. Also, are you trying to pass a recordset to the report, or does your report connect directly to the ODBC connection? Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken,
I'm trying to use the Report Designer Component with a .rpt file, as described in your Crystal/VB Quick Reference. I'm trying to connect directly to the Oracle 8i database through ODBC.

Regards,
DynamicArray
 
There is a page in the back that gives the syntax for using the more common commands LogonServer and SetLogonInfo. Have your tried those?
Do you need LogonServerEx? The syntax is almost identical to LogonServerEx, except LogonserverEx has 2 added arguments for ServerType and connection string.

To confirm your DLL, go to the Database menu in CR designer, and select the "convert driver ...." command. It will tell you what dll your report is using currently. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken,
I've tried LogonServer, LogonServerEx (each with and without DSNs) and SetLoginInfo, and all say 'Error detected by database DLL' (using p2sodbc.dll) or 'Server has not yet been opened' (using pdsora7.dll - from the CR designer).

How do I know whether I need LogonServer or LogonServerEx?

DynamicArray
 
I haven't worked with the Ex version, but it appears you would need it if you need to specify a connection string or server type.

Which dll is your RPT file currently using?
Have you gotten any other reports to launch from your application?
Post the code you used with SetLogonInfo. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
The reports are currently using pdsora7.dll

We can launch reports from VB, but only if they have saved information, and only using:
Code:
Set report = crxApplication.OpenReport("Cancellations By Product.rpt")
report.Database.Tables(1).SetLogOnInfo "myServer", "myDatabaseName", "myUsername", "myPassword"

If we try this with a report that doesn't have saved information, the 'Enter Parameter Values' dialogue appears, but when the OK button is pressed an error saying 'Server has not yet been opened' appears (I'm getting a little sick of that message :-I ).

Thanks,
DynamicArray
 
If the report has saved info, then you shouldn't need any connection info at all. So that test doesn't really tell you anything about the connection.

If you are using pdsora7.dll, then why are you using "p2sodbc.dll" argument in your LogOnServer command? That may be the key to your problem. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken,
I have tried pdsora7.dll already, and it gives the 'Server has not yet been opened' error!

DynamicArray
 
If you look at the Crystal Web site, they strongly urge you to use their Oracle ODBC driver, not the Microsoft driver or the Oracle ODBC driver.

You can download theirs. It's made by Merant.
 
Okay, I think I figured it out. I had the same problems testing a simple Oracle report. "Server not opened" a bunch of times. This is what worked:

Report.Database.Tables(1).SetLogOnInfo "CROR8", "dbname", "user", "password"

The first parameter, CROR8, is the Server Name that you see when you do a Set Location on the report. It is also, for me, the name of the Crystal Merant Oracle ODBC driver.

The second parameter is the name of your Oracle database. This "dbname" should be in your tnsnames.ora config file on your C: drive.

Parameters 3 and 4 are, of course, the username and password to connect successfully.
 
That sounded promising, but unfortunately it didn't work (you've guessed it, 'Server has not yet been opened').

Here are the parameters I have set (replaced for obvious reasons):
(In Crystal Reports)
Dll used: pdsora7.dll (the Crystal Oracle driver didn't work)
Server Type: Oracle Server
Server Name: myServer
Database:
User ID: myUsername

(In tnsnames.ora)
TNS name: myTNSName (coincidentally the same as myServer)

(Database Settings)
User ID: myUsername
Password: myPassword

Here are the code combinations I have tried, and errors in red:
1)
Code:
report.Database.SetDataSource "Provider=OraOLEDB.Oracle.1;Password=myPassword;Persist Security Info=True;User ID=myUsername;Data Source=myTNSName"
crMyViewer.ReportSource = frmTest.report
crMyViewer.ViewReport
Displays 'Enter Parameter Values' dialogue, and 'Server has not yet been opened' info box after entering values

2)
Code:
report.Database.LogOnServerEx "pdsora7.dll", "myServer", , "myUsername", "myPassword", "Oracle Server", "Provider=OraOLEDB.Oracle.1;Password=myPassword;Persist Security Info=True;User ID=myUsername;Data Source=myTNSName"
'Server has not yet been opened' error immediately

3)
Code:
report.Database.LogOnServerEx "pdsora7.dll", "CROR8", , "myUsername", "myPassword", "Oracle Server", "Provider=OraOLEDB.Oracle.1;Password=myPassword;Persist Security Info=True;User ID=myUsername;Data Source=myTNSName"
'Server has not yet been opened' error immediately

4)
Code:
report.Database.LogOnServer "pdsora7.dll", "myTNSName", "myTNSName", "myUsername", "myPassword"
'Server has not yet been opened' error immediately

5)
Code:
report.Database.LogOnServer "pdsora7.dll", "myTNSName", , "myUsername", "myPassword"
'Server has not yet been opened' error immediately

6)
Code:
report.Database.Tables(1).SetLogOnInfo "CROR8", "myTNSName", "myUsername", "myPassword"
crMyViewer.ReportSource = frmTest.report
crMyViewer.ViewReport
Displays 'Enter Parameter Values' dialogue, and 'Server has not yet been opened' info box after entering values

7)
Code:
report.Database.Tables(1).SetLogOnInfo "myTNSName", "myTNSName", "myUsername", "myPassword"
crMyViewer.ReportSource = frmTest.report
crMyViewer.ViewReport
Displays 'Enter Parameter Values' dialogue, and 'Server has not yet been opened' info box after entering values

Are there any more code samples I could try, or am I missing something obvious?

Thanks,
DynamicArray

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top