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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing Crystal report thru VB 6.0

Status
Not open for further replies.

pashu

Programmer
Sep 14, 2003
24
IN
Hi Friends,

I'm not able to connect to my oracle 8i database when executing crystal reports 7.0 thru Vb 6.0. I've written sql in crystal reports.
My connection is thru DSN and my code in vb is

cr1.discardsavedata=true
cr1.action=1

Please help me i'm struggling from last 7 days,its very urgent if possible send me the code written in vb,waiting for ur reply guys.Very Urgent ...................

Thanks & Regards,
Pashu
 
It appears that you are using the RDC, but is that true? If so, I would recommend reviewing the pdf from Crystal Decisions linked below. It contains many examples for vb, including how to logon to a database. The samples for Crystal 8 should work with the CR 7 RDC.


Specifically, you should look at the following item:


The method that relates to loging onto your database is the SetLogonInfo method of the table object or the LogonServer method of the application object.
 
Hi FvTrainer,

I'm not able to get the solution thru ur link please help me if u have any code or have done before..thanking you.

Pashu.
 
Ok, but I need to know a few more pieces of info:

1) Are you using the RDC (CRAXDRT.DLL)? If not, what method are you using for accessing the runtime engine?

2) What driver are you using for your DSN (ODBC or a Native Oracle driver)?
 
Hi FVTrainer,

Thanks for ur prompt reply,

1. I'm using Seagate Crystal Reports 7.0.I've designed the report in crystal report designer and written the query in Sql Designer.

2. I'm connecting to oracle thru user DSN and is using oracle ODBC driver.

Thanks & Regards,
Prashant.
 
Well, the code samples I have are for CR 8. Also, I haven't worked with the SQL Designer in the scenario you have...the SQL Designer is generally to be avoided.

Here is the code sample. I think it should work in your situation, but I'm not positive. In the line of code that uses the SetLogonInfo method, I first used the preceding debug lines to obtain the values for the server and database arguments. So run only those two statements (and nothing after the end of the For..Next loop if you want to avoid any errors) to determine your server and database arguments, then substitute them for the two "mftp" items you see in the SetLogonInfo method. Change your user id and password as necessary.

Dim crApp As New CRAXDRT.Application
Dim crRpt As CRAXDRT.Report

Private Sub Form_Load()

Dim crTable As CRAXDRT.DatabaseTable

Set crRpt = crApp.OpenReport("C:\Appsdata\Crystal\Developer Testing\CR Query Report.rpt")

For Each crTable In crRpt.Database.Tables
Debug.Print crTable.LogOnServerName
Debug.Print crTable.LogOnDatabaseName
crTable.SetLogOnInfo "mftp", "mftp", "sa", "password"
Debug.Print "Connectivity: " & crTable.TestConnectivity
Next

CRViewer1.ReportSource = crRpt
CRViewer1.ViewReport


End Sub
 
Hi FVTrainer,

I copied ur code in vb by changing the login and passwd but after executing the code i'm getting runtime error
Invalid TLV record,what is this error.

Thanks.
Pashu.
 
TLV error messages are evil. Basically, it means that the schema Crystal stores concerning the recordset that should be returned (number of fields and data types) doesn't match what is actually coming into the report.

Have you changed the sql query at all since you designed the report? If so, open the report and choose the Database | Verify Database menu option. See if that helps.

If that doesn't help, I really don't have any more answers. Why are you using the SQL Designer? Is the SQL Statement too complex to use the Visual Linking Expert in Cystal? If you can use the Visual Linking Expert to create the joins and the Record Selection Formula to filter the report, then I would re-engineer the report to use those features and eliminate the use of the SQL Query Designer. And, if stored procedures are an option, I'd look into writing and using a stored procedure as the datasource over using the SQL Designer.
 
Hi FV,

Thanks again for ur prompt reply.I will try as per ur suggestions both with visual linking expert and stored procedure ,actually my report is too complex so i've written the sql please send ur personal email id so that i can attach my report so that u can have a better idea, otherwise send me the steps how to proceed with visual linking expert and also with stored procedure.

Thankin You.

Pashu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top