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

VF7 Front End ,Crystal 9 Report Writer and SQL 2000 DB

Status
Not open for further replies.

Triplex

Programmer
Oct 10, 2002
43
PH

Dear all,

I'm looking for a sample code integrating Crystal 9 into VF7 with SQL2000 as database. Can you give me one? Most of the sample code used Access,Foxpro DB as database.

Im now using an RDC.

Thanks and God Bless.
triplex
 
MikeLewis,

I already visit the site but most of the code use VF database or Access database. I cant find sample using an SQL database.

Thanks.
Triplex
 
Triplex,

When you say "SQL database", I assume you mean SQL Server or a similar back end.

Crystal Reports can access SQL Server in much the same way as it accesses VFP data. It's just a question of changing the ODBC data source.

Your VFP front-end code (the code that calls the RDC) should be the same, regardless of the data source for the report.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike,

Just to give you an idea of what I'm trying to say here is my code.

I have 2 forms the first one is the form where in I have
to select what report to preview.

option button:
Report 1 -->> "F:\Acctapps\Report\SI_BOOK.Rpt"
Report 2 -->> "F:\Acctapps\Report\CSI_BOOK.Rpt"
Report 3 -->> "F:\Acctapps\Report\BDN_BOOK.Rpt"
Report 4 -->> "F:\Acctapps\Report\BCN_BOOK.Rpt"

---cmdView.Click

Do Case
Case Option1.Value = 1
DO FORM f:\acctapps\gl_001\h_gl\f_crystal WITH "f:\ACCTAPPS\REPORT\SI_BOOK.RPT"
Case Option2.Value = 2
DO FORM f:\acctapps\gl_001\h_gl\f_crystal WITH "f:\ACCTAPPS\REPORT\CSI_BOOK.RPT"
...
Endcase


My second form is for viewing the report.


--Init
LPARAMETERS tcReport
LOCAL oCrystal as CRAXDRT.Application
LOCAL oReport as CRAXDRT.Report

WITH This
.WindowState = 2
oCrystal = CREATEOBJECT("Crystalruntime.Application")
oReport = oCrystal.OpenReport(tcreport)

WITH .oleCRViewer
.EnableExportbutton = .t.
.EnableProgressControl = .t.
.ReportSource = oReport
.EnableAnimationCtrl = .f.
.ViewReport()
ENDWITH
ENDWITH

--Activate
WITH this.oleCRViewer
.top = 1
.left = 1
.height = thisform.Height - 2
.width = thisform.Width - 2
ENDWITH

--Error
LPARAMETERS nError, cMethod, nLine

IF nerror !=1440
DODEFAULT()
ENDIF

--Resize
WITH This.OleCRViewer
.top =1
.left =1
.height =this.Height - 2
.width =this.Width - 2
ENDWITH


When I run the report I come up with an error:

Logon failed.
Details:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'USER'

I tried to add this code but same problem
oCrystal.LogOnServer("p2ssql.dll","FINANCE","HPI_GL","user","grant")

thanks

triplex






 
Triplex,

Have you tried running your report independently of VFP, that is, from within Crystal Reports? If so, do you get a similar message? If so, check the ODBC parameters, especially the user name, password and default database.

If it works within Crystal, go back to your VFP code and call the SetLogonInfo() method of the table objects. The syntax is something like this:

oReport.Databases.Tables(1).SetLoginInfo("MyODBCSource","MyDatabase","MyUserName","Mypassword")

If you have more than one table, repeat the above for each of them.

You might also have to set the Name and Location properties of each of these tables. In each case, set these just to the name of the table (the same setting for Name and Location).

Give that a try and let us know if it works.

Mike



Mike Lewis
Edinburgh, Scotland
 
Mike,

I tried the code but still the same error.

Thanks.
Triplex
 
It's not a Crystal Reports error, but a problem connecting or logging into the database. Make sure the DSN is setup correctly.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top