Click here to Skip to main content
15,881,742 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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|\MyDatabase.mdf;Integrated Security=True;User Instance=True
where MyDatabase=database name
application runs fine but 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.

My code is:

C#
public void Refreshreport()
{
   //I've added the report file (BalanceCrystalReport.rpt)to my project, 
   //and create an instance of the file. 
   var report = new BalanceCrystalReport();

   foreach (ReportDocument doc in report.Subreports)
   {
           foreach (Table table in doc.Database.Tables)
                table.ApplyLogOnInfo(MyTableLogOnInfo);

           doc.SetDatabaseLogon("", "",".\\SQLEXPRESS", "MyDatabase");
   }
   crystalReportViewer.ReportSource = report;
}

public virtual TableLogOnInfo MyTableLogOnInfo
{
  get
  {
      if(myTableLogOnInfo == null)
      {
          myTableLogOnInfo = new TableLogOnInfo();

          myTableLogOnInfo.ConnectionInfo.ServerName = ".\\SQLEXPRESS";
          myTableLogOnInfo.ConnectionInfo.DatabaseName = "MyDatabase";
          myTableLogOnInfo.ConnectionInfo.UserID = "";
          myTableLogOnInfo.ConnectionInfo.Password = "";
          myTableLogOnInfo.ConnectionInfo.IntegratedSecurity = true;
      }
      return myTableLogOnInfo;
}
Posted
Updated 6-Jul-12 3:07am
v5

1 solution

try to add username and password in your connection string
 
Share this answer
 
Comments
B.Farivar 6-Jul-12 9:01am    
I want have to connect with windows authentication.
MAU787 6-Jul-12 14:22pm    
then you create guest as a user in sql server management studio and give him all rights...
it will solve the problem
B.Farivar 7-Jul-12 12:13pm    
I deploy my project(with Sql Express and all prerequirements) with a setup file witch created with VS2008 and i can't create a user in deploym time.

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