Link to home
Start Free TrialLog in
Avatar of Altaf Patni
Altaf PatniFlag for India

asked on

How to Create Crystal Report

Hi
I have created a couples of Crystal reports all reports are connected with MS Access DB.

Now i have switched from ms access to SQL SERVER2008
Ans how all this report convert from access to SQL

and honestly i dont know how to connect with sql server.

Please explain me step by step

I am using Crystal report 7.0 (Old version)
and Database = SQL SERVER 2008 R2
Avatar of Seaton007
Seaton007
Flag of United States of America image

Avatar of Mike McCracken
Mike McCracken

I have my doubts that CR 7 will connect with SQL Server 2008 R2

I know there were some updates requred to connect with SQL Server 2000

You probably need to create an ODBC connection to SQL Server
Be sure you use the 32-bit ODBC connection wizard.  CR7 is 32-bit only.

Once created you should be able to choose it when you create a report as the data source under ODBC connections

mlmcc
Avatar of Altaf Patni

ASKER

Thanks for Quick Reply.

I tried following thing

Creating New Report using  CR7
In Standard Report Expert..
There is
Data File
Query
SQL/ODBC
Dictionary
OLEDB
etc.....

Clicked on SQL/ODBC
windows displayed

Log on Server

server Type i have choosed
Active Data (ADO)

Clicked on OK
Window displayed - Select Data Source

There is Four Options
1- ODBC(ADO)
2- ADO and OLEDB
3- DAO (This option is disable)
4- Data Definition (This option is disable)

Selected First option ODBC(ADO)
Clicked on NEW
window displayed
Create New Data Source
Selected First Option
File Datasourse (Machine Independent)
Clicked on NEXT
Selected Driver
SQL Server
Clicked on NEXT
Typed Name of DSN (MyServerPrint)
Clicked on NEXT
typed name of My SqlServer in server box
clicked on NEXT
Authenticity of the login ID..?
Selected Second option (with SQL Server Authentication)
Login Id = myloginid
Password = myPassword
clicked on NEXT
Changed default database to MyDatabase
clicked on NEXT
clicked on NEXT
clicked on FINISH
Clicked on TEST DATA SOURCE
TESTS COMPLETED SUCCESSFULLY
OK
OK
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Now Whats the next step..?

How can i drag and drop fields from sql table to report
ok now i got it ..
but now problem is
i am getting

Runtime error  '20599'
Can Not Open SQL Server

Using following code

    
' My Connection string is
    CON.Open _
            "Provider = sqloledb;" & _
            "Data Source=MYSERVER;" & _
            "Initial Catalog=MYDB;" & _
            "User ID=MYID;" & _
            "Password=MYPASS;"

if CON.State =  1 
                  '''Do Nothineg
else
 CON.Open
end if

CrystalReport1.ReportFileName = App.Path & "\CUST.rpt"
CrystalReport1.Connect = CON
    CrystalReport1.DiscardSavedData = True
    CrystalReport1.RetrieveDataFiles
CrystalReport1.SelectionFormula = "{SQLTABLE.Field1} = " & Text1.Text & ""
    CrystalReport1.Formulas(1) = "Field2= '" & Text1.Text & "'"

    CrystalReport1.Destination = crptToWindow
    CrystalReport1.Action = 1

Open in new window

Have you built a report?

Try moving the discard saved data line up 1 so it is just after you open the report

mlmcc
<< Have you built a report? >>
Yes and its working fine from CRYSTAL it self.

But NOT from my code.

You mean like this..?
if yes then i tried .. it still same error.


CrystalReport1.ReportFileName = App.Path & "\CUST.rpt"
CrystalReport1.DiscardSavedData = True
CrystalReport1.Connect = CON
Tried this one .. but no luck

CrystalReport1.Connect = "DSN=MyPrintCon;UID:MyID;PWD:Mpwd;DSQ=MyDatabase;"

Open in new window

Your version is old enough that I don't recall how to connect that way.

mlmcc
is there any other way .. because more than 30 reports allredy created.. and need to waiting for switch into SQL Server 2008
Tried following code
But still same error i am getting.

from crystal environment its working fine.


CrystalReport1.ReportFileName = App.Path & "\Cust.rpt"
CrystalReport1.Connect = "Provider=SQLOLEDB.1;Password=*****;Persist Security Info=True;User ID=****;Initial Catalog=CustDetail;Data Source=ServerName"
CrystalReport1.RetrieveDataFiles
CrystalReport1.Destination = crptToWindow
CrystalReport1.DiscardSavedData = True
CrystalReport1.Action = 1

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i think problem is my DSN
i have created dsn.. i checked and configured it.. it wasn't work
and also it was not in the ODBC registry even not in the system DSN

so i have registered DSN through regedit

and now it is working fine..
like charm

over all my code is
   
CrystalReport1.ReportFileName = App.Path & "\Cust.rpt"
CrystalReport1.Connect = "DSN=MyCon;UID=xxxxx;PWD=xxxx;DSQ=MyDatabase" 

CrystalReport1.RetrieveDataFiles
CrystalReport1.Destination = crptToWindow
CrystalReport1.DiscardSavedData = True
CrystalReport1.Action = 1

Open in new window

Thanks.
Problem was DSN