Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
Hi,

I am trying to deploy crystal reports 2008 on shared server. Before publishing on the remote server i published it on the localhost while connecting it to remote sql server 2008 database. The report is shown perfactly but when i publish it on shared server it prompt me for login credentials. My hosting provider is arvixe and it support crystal report. In my popup database field is empty and locked use name field show the correct user name and password field is empty. I read somewhere it may be due to version conflict between my version and version on server. Thanks in advance for help.

I am using dataset to puch my data to report. Here is my source code:
C#
myRpt report = new myRpt();
crConnectionInfo.ServerName = @"mysharedserver.com";
crConnectionInfo.DatabaseName = "mydb";
crConnectionInfo.UserID = "myuser";
crConnectionInfo.Password = "mypass";
                        
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection();
myConnection.ConnectionString = "Data Source=mysharedserver.com;Initial Catalog=mydb;Persist Security Info=True;User ID=myuser;Password=mypass";
            
System.Data.SqlClient.SqlCommand MyCommand = new System.Data.SqlClient.SqlCommand("dbo.spspMyStoreProc");
MyCommand.Connection = myConnection;
MyCommand.Parameters.Add("@PositionID", SqlDbType.Int).Value = (cmbPositions.SelectedValue == "" ? 0 : Convert.ToInt32(cmbPositions.SelectedValue));
MyCommand.CommandType = System.Data.CommandType.StoredProcedure;
System.Data.SqlClient.SqlDataAdapter MyDA = new System.Data.SqlClient.SqlDataAdapter();
MyDA.SelectCommand = MyCommand;
myDS _DS = new myDS();
MyDA.Fill(_DS, "dbo.spspMyStoreProc");            
report.SetDataSource(_DS);

crDatabase = report.Database;
crTables = crDatabase.Tables;
for (int i = 0; i < crTables.Count; i++)
{
  crTable = crTables[i];
  crTableLogOnInfo = crTable.LogOnInfo;
  crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
  crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

report.SetParameterValue(0, "Param 1");
report.SetParameterValue(1, "Param 2");
report.SetParameterValue(2, "Param 3");
report.SetParameterValue(3, (cmbPositions.SelectedValue == "" ? 0 : Convert.ToInt32(cmbPositions.SelectedValue)));
CrystalReportViewer1.ReportSource = report;
Posted
Updated 21-Feb-11 19:34pm
v2
Comments
JF2015 22-Feb-11 1:35am    
Edited to fix code formatting.

1 solution

Helloo...!

Just Add this line before assigning report to reportviewer....!

report.SetDatabaseLogon("yourusername", "yourpassword");
 
Share this answer
 

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