Error : Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'UserXXX'. SQL State: 42000 Native Error: Error in File E:\TEMPSY~1\Tmp\temp_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.rpt: Unable to connect: incorrect log on parameters.
Solution :
Open the report, then Verify Database, using the login used while deploying!This error takes me a lifetime to solve. It actually doesn't make sense to verify database for a report using the real login while deploying. That means all reports created while developing will have to be verified. The login info should be able to be set programmatically.
In my case, there are already some pages on the web that use similar reporting. I've printed the report using the same code, but no matter how I try, none works. I've tried a lot of ways to make it print, but all to no avail.
At last, I verify the report using the login used while deploying, then re-upload it. It works fine. phew -.-""""""
I set the login information for the report from web.config:
<!--<add key="ConnectionInfo" value="Database_name, server, user, password">-->
<add key="ConnectionInfo" value="DB1, 10.20.20.9, steven, steven"||/add>
Here's the .cs code I use for the report, and it should work fine, I guess.
private void BindConnectionInfo()
{
ConnectionInfo connectionInfo = new ConnectionInfo();
string conInfo = SystemConfiguration.ConnectionInfo; //get from web.config
connectionInfo.DatabaseName = conInfo.Split(',')[0].Trim();
connectionInfo.ServerName = conInfo.Split(',')[1].Trim();
connectionInfo.UserID = conInfo.Split(',')[2].Trim();
connectionInfo.Password = conInfo.Split(',')[3].Trim();
TableLogOnInfo t = new TableLogOnInfo();
t.ConnectionInfo = connectionInfo;
if (crystalViewer.LogOnInfo.Count == 0)
{
crystalViewer.LogOnInfo.Add(t);
}
crystalViewer.EnableDatabaseLogonPrompt = false;
crystalViewer.EnableParameterPrompt = false;
}
protected void btnPrint_Click(object sender, EventArgs e)
{
litXXX.Text = "";
//Print
BindConnectionInfo();
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("../../Report/report_name.rpt"));
ParameterDiscreteValue value = new ParameterDiscreteValue();
value.Value = Period;
ParameterValues parameterValuesPriod = new ParameterValues();
parameterValuesPriod.Add(value);
value = new ParameterDiscreteValue();
value.Value = Convert.ToByte(Semester);
ParameterValues parameterValuesSem = new ParameterValues();
parameterValuesSem.Add(value);
ParameterField parameterField = rd.ParameterFields[0];
parameterField.DefaultValues = parameterValuesPriod;
parameterField.CurrentValues = parameterValuesPriod;
parameterField = rd.ParameterFields[1];
parameterField.DefaultValues = parameterValuesSem;
parameterField.CurrentValues = parameterValuesSem;
crystalViewer.ReportSource = rd;
crystalViewer.DataBind();
}
And here's the .aspx code:
script type="text/javascript">
<!--
function PrintPartsViewer()
{
var objWindow = window.open("about:blank", "print", "width=800, height=600, toolbar=no");
var strHtml = "<html>";
strHtml += "<head>";
strHtml += "</head>";
strHtml += "<body>";
var element = document.getElementById("divPrint");
strHtml += element.innerHTML;
strHtml += "</body>";
strHtml += "</html>";
objWindow.document.write(strHtml);
objWindow.document.close();
objWindow.print();
objWindow.close();
}
//-->
</script>
<asp:literal id="litXXX" runat="server"></asp:literal>
<asp:button id="btnPrint" runat="server" text="Print Report" onclick="btnPrint_Click" />