hello,

I am using CR8 with vb6. I have created a report using icr designer. The report connects to the database using a system dsn. The report uses the tables emp_mast and pay_det. For testing I put the the fields emp_name and emp_designation from emp_mast in the report and viewed the report. It worked perfectly well.

Now my special requirement is that I will be using separate databases with the same datastructure for reporting at different occasions as I will be receiving different databases from field offices. In other words, I will be selecting the datasource for the reports every time I open the application. To try this, I tried the following code,

VB Code:
  1. Dim Dim strSql As String
  2. Dim rst As ADODB.Recordset
  3. Dim cnn As ADODB.Connection
  4. cnnString As String
  5. Dim Report As New rptAdmitCard
  6.  
  7.     cnnString = "Provider=MSDASQL; DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\mydir\mydb.mdb; UID=; PWD=;"
  8.  
  9.     Set cnn = New ADODB.Connection
  10.     cnn.Open cnnString
  11.     strSql = "select * from emp_mast"
  12.     Set rst = New ADODB.Recordset
  13.     rst.Open strSql, cnn, adOpenStatic, adLockReadOnly, adCmdText
  14.  
  15.     Report.Database.SetDataSource rst
  16.     Screen.MousePointer = vbHourglass
  17.     CRViewer1.ReportSource = Report
  18.  
  19.     CRViewer1.ViewReport
  20.     Screen.MousePointer = vbDefault
  21.     rst.Close
  22.     cnn.Close
  23.     Set rst = Nothing
  24.     Set cnn = Nothing

But the report is still displaying from the old database only, not from mydb.mdb

Will someone pls tell me where I have gone wrong ???
thanx

jojy