views:

218

answers:

1

How to open the sql data base in crystal report?

Using VB 6, SQL server 2000, Crystal Report 8.5

My code.

CR.DataFiles(0) = App.Path & "\Database\DUAL_ACS.mdf"
CR.ReportFileName = App.Path & "\rpt_attendancereport.rpt"
CR.Action = 1

But it showing “Cannot Open Sql Server”

What wrong in my code.

Need VB 6 code Help?

+1  A: 

Instead of

CR.DataFiles(0) = App.Path & "\Database\DUAL_ACS.mdf"

try

CR.Connect = <<connection string to SQL Server goes here>>

Connection string should be in the format:

"DSN=<<server name here>>;" & _
"UID=<<user name here>>;" & _
"PWD=<<password here>>;" & _
"DSQ=<<database name here>>"

Just to clarify the 'DSN' bit isn't actually a DSN; rather, it has been overloaded to mean 'SQL Server name'.

onedaywhen