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

Trouble in Crystal reports for accessing the Database

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
This is my code ,
but there is no error in the code , i am not able to see
any records in the CRViewer,
I am using seagate crystal reports 7.0
I have populated the report with tables, and it is not empty report, kindly give the solution to this problem


Dim Report As New CrystalReport1

Private Sub Form_Load()
Screen.MousePointer = vbHourglass

Dim ado As ADODB.Connection

Dim rs As ADODB.Recordset
Dim query As String
Set ado = New ADODB.Connection
ado.ConnectionString = modMain.dbconnection
ado_Open "mashoodtestdsn"

query = "select * from department"
Set rs = ado.Execute(query)

Report.DisplayProgressDialog = True

Report.DataBase.SetDataSource rs, 3, 1



CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub
thanks
regds shubha
email : shubha_cd@rediffmail.com
 
The code looks pretty much okay. I've never used the 3rd parameter, just leaving it .SetDataSource rs, 3

Did you build the report in Crystal with the Active Data Driver?

Does you SQL in VB match the SQL you created in the report?

Are you sure that the rs recordset has records in it just before you pass it to the report?

You could also put some On Error code in VB to trap any VB errors.

 
hello,
thanks for replying,
as u told i have not used the active data driver,
first i chose empty report in crystal reports
that is in the designer's group of the project explorer in VB.
from there i clicked the database feilds in the report, to populate it with the tables ,there i chose , log on server
there i got my dsn, "odbc-mydsn",and added the required tables.till i drag and drop the feilds in the crystal report desinger section i won't get any records on the viewer, but i don't want this , the records should be displayed through my code without me actullay drag and drop,
i will put the error code and try,
pls kindly reply
thanks
regds
Shubha
 
I don't think you should be passing an ADO recordset from VB if you're not using the Active Data Driver when you're creating the report.

You can pick the Active Data Driver when creating a new report and paste in the SQL statement that is the same SQL statement that you will use from VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top