Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
2.40/5 (2 votes)
See more:
Hi All,

I have copied .mdf and .ldf files of database in bin/debug folder of my application and used the connection string as follows

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hm.mdf;Integrated Security=True;User Instance=True
where hm=database name
application runs fine but now i am getting new error while running and after creating set up file.I copied .mdf file and .ldf file in set up project and also in bin/release folder and then total application runs fine but now i am getting error in crystal report asking for user name and passwords.

Please suggest me for the same.

Thanks in Advance.
Posted
Updated 15-Jun-11 22:14pm
v2
Comments
karan joshua 16-Jun-11 4:13am    
In crystal report have u given user name and password?

1 solution

We are also getting the same error, then we will create a data set and pass the record to report (Where crystal report viewer is) . Its call Push report.



Here is the code

ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
MIDL
cryRpt.Load(System.Windows.Forms.Application.StartupPath + "\\PickListRpt.rpt");


MIDL
crConnectionInfo.ServerName = lstrServerName;
              crConnectionInfo.DatabaseName = lstrDatabaseName;
              crConnectionInfo.UserID = lstrUserName;
              crConnectionInfo.Password = lstPass;


string lstrQry =" Your Query ";

SqlConnection con = new SqlConnection(clsUserInterface.ConnectionString);
SqlDataAdapter dr = new SqlDataAdapter(lstrQry, con);

DataSet1 ds2 = new DataSet1();

dr.Fill(ds2.Tables["dtReport"]);
cryRpt.SetDataSource(ds2);
MIDL
crystalReportViewer3.ReportSource = cryRpt;
                crystalReportViewer3.Refresh();
 
Share this answer
 
Comments
mayur csharp G 17-Jun-11 1:01am    
My dear friend after doing this whatever database fields i have dragged on crystal reports as per my previous technique will remain same or i will have to do some different again

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