I am using windows 7 ,SQL Server 2000 and VS 2008 / Crystal Report XI.
i am getting Below Error when click on GetReport Button.
Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'sa'. SQL State: 42000 Native Error: Error in File C:\Users\bahadur\AppData\Local\Temp\Total_Sales_Comparision {C4649F80-D1F7-4AED-A4B1-0B8EF83996C6}.rpt: Unable to connect: incorrect log on parameters. Blockquote
MY C# Code is below
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "BRAVEALI-PC";
crConnect开发者_StackOverflow中文版ionInfo.DatabaseName = "SCM_TEST";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "myDB Password";
ReportDocument report = new ReportDocument();
report.Load(@"D:\Project's\SCM Reports\Total_Sales_Comparision.rpt");
report.SetParameterValue("@invcm_date_from", Convert.ToDateTime (TextBox4.Text));
report.SetParameterValue("@invcm_date_to", Convert .ToDateTime(TextBox5.Text));
CrystalReportViewer1.ReportSource = report;
//CrystalReportViewer1.RefreshReport();
Regards
Brave Ali
You never did anything with your crConnectionInfo object... you did not tie it back to you Report object.
It's giving you incorrect login info because you never set the login info.
use this code for setting login info,
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "Servername";
crConnectionInfo.DatabaseName = "Database";
crConnectionInfo.UserID = "Userid";
crConnectionInfo.Password = "password";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
or simply use
yourreport.setdatabaselogon("username","Password","servername","databasename");
精彩评论