Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,
i need to know how to set crystal Report data source as application start up path...
Problem: After deployment it requires the db which i used in the report design.


i tried,
C#
ReportDocument rd=new ReportDocument();
rd.SetDatabaseLogon("username","password","Application.StartupPath","MyDB");


but it is not working...

Can any one give me solution Please....
Posted

you need to set the database source at run time.
VB
Dim cRep As New CrystalReport1
Dim crConInfo As New ConnectionInfo
Dim crLogInfo As New TableLogOnInfo
With crConInfo
    .ServerName = "ServerName"
    .Database = "Database"
    .UserID = "UID"
    .Password = "PWD"
End With

crLogInfo.ConnectionInfo = crConInfo
cRep.Database.Tables(0).ApplyLogOnInfo(crLogInfo)


Don't forget to use ApplyLogoninfo it will change the login details of the objects used in the report and then only report will work with the new database.

HTH.
 
Share this answer
 
Comments
Shanmugam Rathakrishnan 18-Jun-12 5:29am    
hi, Thanks for ur reply...
i tried by what u said above but the problem is not solved yet...
i am using 2 tables in my report both r individual tables and both r mentioned in sub-reports(subrep1,subrep2) of cryatalreport1.
i also using record selection formula for both sub-reports.
So i wrote the by this...

rd.Load(AppDomain.CurrentDomain.BaseDirectory + "CrystalReport1.rpt");
ConnectionInfo coninfo = new ConnectionInfo();
coninfo.DatabaseName = "Stock.mdb";
coninfo.ServerName =Application.StartupPath;
coninfo.UserID = "u1";
coninfo.Password = "pwd";

TableLogOnInfo tableconinfo = new TableLogOnInfo();
tableconinfo.ConnectionInfo = coninfo;
CrystalReport1 cr1 = new CrystalReport1();

cr1.Subreports[0].Database.Tables[0].ApplyLogOnInfo(tableconinfo); cr1.Subreports[1].Database.Tables[0].ApplyLogOnInfo(tableconinfo);

pls guide me is that right r wrong...
Make sure you are applying the connection info to the crystal report object that you have loaded.
 
Share this answer
 
Comments
Member 10019921 28-Aug-13 7:29am    
im also using crystal report . in my report we export 2 sheet bill per sheet 8 lines. fist sheet bill location start point is correct but at end of the bill 9 th line also printing so second sheet bill position will change to start of page . how i fix correct position where i need to?
rp.PrintOptions.PrinterName = prname;
pd.DefaultPageSettings.PaperSize = new PaperSize("mypaper", 1000, 600);
rp.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
string rpp = rp.PrintOptions.PaperSize.ToString();
rp.PrintToPrinter(1, false, 1, 2);
this code only imm using..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900