Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi, all.

I think this is one of the big issue using Crystal Report I've countered.

 

I'm using Crystal Report written in version 8.5

and .NET application call it and show report with Report Viewer.

But, whenever I show the report, it keep showing Database Login dialog box with EMPTY Password box.

 

I think my code is normal and standard!

Is it Report problem or any other problem?

Please take a look and give me any comment.

It will be big help.

Thank you..

 

Following are sp, code..

 

 

...
CrystalDecisions.Shared.ParameterFields paramFields= new ParameterFields();
		ParameterField paramField;
		ParameterDiscreteValue discreteVal;
		paramField = new ParameterField();
		discreteVal = new ParameterDiscreteValue();
			
		paramField = new ParameterField();
		discreteVal = new ParameterDiscreteValue();
		paramField.ParameterFieldName = "@CompanyCode";
		discreteVal.Value = "M3E";
		paramField.CurrentValues.Add(discreteVal);
		paramFields.Add(paramField);

		paramField = new ParameterField();
		discreteVal = new ParameterDiscreteValue();
		paramField.ParameterFieldName = "@DepartmentCode";
		discreteVal.Value = "COM";
		paramField.CurrentValues.Add(discreteVal);
		paramFields.Add(paramField);

		paramField = new ParameterField();
		discreteVal = new ParameterDiscreteValue();
		paramField.ParameterFieldName = "@FROM";
		discreteVal.Value =  "12/01/2003";
		paramField.CurrentValues.Add(discreteVal);
		paramFields.Add(paramField);

		paramField = new ParameterField();
		discreteVal = new ParameterDiscreteValue();
		paramField.ParameterFieldName = "@TO";
		discreteVal.Value = "12/28/2003";
		paramField.CurrentValues.Add(discreteVal);
		paramFields.Add(paramField);

		TableLogOnInfos logOnInfos = new TableLogOnInfos();
		TableLogOnInfo logOnInfo = new TableLogOnInfo();
		logOnInfo.ConnectionInfo.ServerName = "MIS108";
		logOnInfo.ConnectionInfo.DatabaseName = "TimeClock";
		logOnInfo.ConnectionInfo.UserID = "RUser";
		logOnInfo.ConnectionInfo.Password = "RUser";
		
		logOnInfo.TableName = "spCompletePayrollReport; 1"; 
		logOnInfos.Add(logOnInfo);
		RptViewer.LogOnInfo = logOnInfos;
		//para info
		ViewReportParameter pr = new ViewReportParameter();			
		RptViewer.ParameterFieldInfo = paramFields;
		//report name
		string rn = Get_ReportName;
		RptViewer.ReportSource = "C:\\Projects\\New Time Clock Release\\New Time Clock HQ\\TimeClockAdmin\\bin\\Debug\\PayrollCompleteReport.rpt";
..

 

/**************************** sp used

CREATE     PROCEDURE spCompletePayRollReport
@UserID 		varchar(6)
,@CompanyCode	varchar(3)  -- char doen't work with '%' + @var
,@DepartmentCode 	varchar(6)
,@FROM 		datetime
,@TO			datetime
AS
 SET NOCOUNT ON
SET @TO = DATEADD(DAY, 1, @TO)
SELECT  @FROM as FromDate, DATEADD(DAY, -1, @TO) as ToDate,   tblPayrollReport.tblID, tblPayrollReport.UserID, (tblUser.FirstName + ' ' + tblUser.LastName) as [Name], 
	tblPayrollReport.CompanyCode, tblPayrollReport.DepartmentCode, tblPayrollReport.Weeks, tblPayrollReport.TimeIn, tblPayrollReport.TimeOut, 
                      tblPayrollReport.JobCode, tblPayrollReport.[break], tblPayrollReport.Hours, tblPayrollReport.Reg, tblPayrollReport.Ovt1, 
                      tblPayrollReport.Ovt2, tblPayrollReport.DayTotal, tblPayrollReport.PayrollPeriodID
FROM         tblPayrollReport INNER JOIN
                      tblUser ON tblPayrollReport.UserID = tblUser.UserID
WHERE    tblPayrollReport.UserID Like '%' + @UserID + '%'
AND tblPayrollReport.CompanyCode LIKE '%' + @CompanyCode
AND tblPayrollReport.DepartmentCode LIKE '%' + @DepartmentCode
AND  (tblPayrollReport.TimeIn >= @FROM) AND (tblPayrollReport.TimeIn < @TO) OR
                      (tblPayrollReport.AdditionalDate >= @FROM) AND (tblPayrollReport.AdditionalDate < @TO)

	SET NOCOUNT OFF

GO

Edited by goodmorningsky

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

Posted

I've tried many ways to fix problem.. but, I still didn't get it.

Interestingly,

I moved the DB to IT009 server and tried it with following changed code.

TableLogOnInfos logOnInfos = new TableLogOnInfos();
		TableLogOnInfo logOnInfo = new TableLogOnInfo();
		logOnInfo.ConnectionInfo.ServerName = "IT009";
		logOnInfo.ConnectionInfo.DatabaseName = "TimeClock";
		logOnInfo.ConnectionInfo.UserID = "sa";
		logOnInfo.ConnectionInfo.Password = "saPwd";			
		logOnInfo.TableName = "spCompletePayrollReport; 1"; 
		logOnInfos.Add(logOnInfo);
		
		RptViewer.LogOnInfo = logOnInfos;

 

When open report DB login window comes out. BUT

THE Login info are those I set in Crystal report defaultly.

for example, Server name is not IT009 but is MIS108.

 

So, it seems that the TableLogOnInfos doesn't work at all.

 

Please help with this..

Any comment helps..

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

Posted

Don't know if you can use this but I had a problem login onto an Access database with database level password.

 

I defined the following as program level variables.

 

ReportDocument crReportDocument = new ReportDocument();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
Tables CrTables;

 

then in my viewer load I did this

 

crReportDocument = new ReportName();

crConnectionInfo.DatabaseName = "DataBase path and name";
crConnectionInfo.Password = "Password";

CrTables = crReportDocument.Database.Tables;

foreach (Table CrTable in CrTables) 
{
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}

 

Hope this Helps

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...