I have deployed my SSRS reports in the server. Is it possible for me to access that report from my local web application. I have given the server's credentials in the web.config. But still its not displaying the report and it shows some error like Cannot create a connection to data source 'DataSource1'. (rsErrorOpeningConnection).
When I hosted the same application in the server it is working absolutely fine.
Can anyone tell me why am not able to access the reports from my local system?
This is not my code, but ideally is all you have to do. I remember using it successfully in one of previous projects some time back
private void ShowReport()
{
try
{
string urlReportServer = "http://sqlDBServer//Reportserver";
rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local
rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer); //Set the ReportServer Url
rptViewer.ServerReport.ReportPath = "/ReportName"; //Passing the Report Path
//Creating an ArrayList for combine the Parameters which will be passed into SSRS Report
ArrayList reportParam = new ArrayList();
reportParam = ReportDefaultPatam();
ReportParameter[] param = new ReportParameter[reportParam.Count];
for (int k = 0; k < reportParam.Count; k++)
{
param[k] = (ReportParameter)reportParam[k];
}
// pass crendentitilas
//rptViewer.ServerReport.ReportServerCredentials =
// new ReportServerCredentials("uName", "PassWORD", "doMain");
//pass parmeters to report
rptViewer.ServerReport.SetParameters(param); //Set Report Parameters
rptViewer.ServerReport.Refresh();
}
catch (Exception ex)
{
throw ex;
}
}
Ref: http://www.codeproject.com/Articles/675762/Call-SSRS-Reports-by-using-Csharp
Related
I'm trying to connect to a CRM 2011 Online environment. I'm able to connect via a "Console Application", but when I'm trying to connect via an "ASP.net"-application with the same code, it doesn't work, it gives me the "Authentication Failure"-error ({"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."}).
Is there something special we need to do to make it work on an "ASP.net" environment. I tested out several solutions I found on the internet, but all gives me the same error.
A "code"-snippet of my simplified code:
private static ClientCredentials GetDeviceCredentials()
{
return Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
}
protected void Button1_Click(object sender, EventArgs e)
{
//Authenticate using credentials of the logged in user;
string UserName = "*****"; //your Windows Live ID
string Password = "*****"; // your password
ClientCredentials Credentials = new ClientCredentials();
Credentials.UserName.UserName = UserName;
Credentials.UserName.Password = Password;
Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
//This URL needs to be updated to match the servername and Organization for the environment.
Uri OrganizationUri = new Uri("https://*****.crm4.dynamics.com/XRMServices/2011/Organization.svc"); //this URL could copy from Setting --> Developer Source
Uri HomeRealmUri = null;
//OrganizationServiceProxy serviceProxy;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))
{
IOrganizationService service = (IOrganizationService)serviceProxy;
OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
var theAccounts = orgContext.CreateQuery<Account>().Take(1).ToList();
Response.Write(theAccounts.First().Name);
}
}
I tried several things, like deleting the content of "LiveDeviceID"-folder an re-running the device registration tool. but is weird that it works in the "console application" but not on my "asp.net"-solution...
PS : I am able to generate the "context"-file via crmsvcutil.exe /url:https://org.crm4.dynamics.com/XRMServices/2011/Organization.svc /o:crm.cs /u:username /p:password /di:deviceUserName /dp:devicPWD
Is there any particular reason you have
Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
You shouldn't need that line for windows live authentication.
Even with that the code seems valid so it is something to do with the Device Registration. I suggest rather than just call it directly like you have
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))
{
You try something like the following because you only need to register once:
ClientCredentials deviceCredentials;
if ((CRMSettings.Default.DeviceID == String.Empty) || (CRMSettings.Default.DevicePassword == String.Empty))
{
deviceCredentials = Microsoft.Crm.Services.Utility.DeviceIdManager.RegisterDevice();
}
else
{
deviceCredentials = new ClientCredentials();
deviceCredentials.UserName.UserName = CRMSettings.Default.DeviceID;
deviceCredentials.UserName.Password = CRMSettings.Default.DevicePassword;
}
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, deviceCredentials))
{
I have had issues in the past where I get an "already registered" response from the RegisterDevice call.
I would also dump out the Device ID and Password so you can see if they are being set.
We are using Crystal Reports 2011 & SQL Server 2008 (Windows 7 64 bit). Whenever I try to deploy the crystal reports in the IIS it is always prompting enter the database login information. I have tried the below options
Set the login information in the code
Set IIS app pool to LocalService
Nothing works. Here is the code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ConfigureCrystalReports();
}
else
{
ReportDocument doc = Session["Report"] as ReportDocument;
SetLogon(doc);
CrystalReportViewer1.ReportSource = doc;
CrystalReportViewer1.RefreshReport();
}
}
private void ConfigureCrystalReports()
{
ReportDocument reportDoc;
if (!IsPostBack)
{
reportDoc = new ReportDocument();
reportDoc.Load(Server.MapPath("~/Sample.rpt"));
Session.Add("Report", reportDoc);
}
else
{
reportDoc = Session["Report"] as ReportDocument;
}
SetLogon(reportDoc);
CrystalReportViewer1.ReportSource = reportDoc;
CrystalReportViewer1.RefreshReport();
}
private void SetLogon(ReportDocument reportDoc)
{
var connectionInfo1 = new ConnectionInfo()
{
ServerName = #"ODBCDSN",
DatabaseName = "hrdw_old",
IntegratedSecurity = true
};
SetDBLogonForReport(connectionInfo1, reportDoc);
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo1, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo1;
tableLogonInfo.ConnectionInfo.Type = ConnectionInfoType.SQL;
table.ApplyLogOnInfo(tableLogonInfo);
}
reportDocument.SetDatabaseLogon(connectionInfo1.UserID, connectionInfo1.Password);
}
}
Steps tried in IIS:
Application pool: ASP.NET 4.0 Default app pool
Also enabled Windows Authentication in IIS & disabled anonymous authentication.
Tried anonymous authentication only.
SQL Server has both windows and sql server authentication.
I will not be able to use dataset since the crystal reports will be developed by someone using command objects. It works perfectly good in the Visual studio 2010 environment. But doesnt work in IIS.
Am I missing something basic? Any help is appreciated.
Thanks
Shankar.
Here is how this was solved. It was a bit of workaround
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc = doc.ReportClientDocument;
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rcd = rptClientDoc;
string server = #"<SERVER>";
string db = "<DATABASE>";
string user = "<USER>";
string pass = "PASSWORD";
rptClientDoc.DatabaseController.LogonEx(server, db, user, pass);
//Create the logon propertybag for the connection we wish to use
CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag logonDetails = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();
logonDetails.Add("Auto Translate", -1);
logonDetails.Add("Connect Timeout", 15);
logonDetails.Add("Data Source", server);
logonDetails.Add("General Timeout", 0);
logonDetails.Add("Initial Catalog", db);
logonDetails.Add("Integrated Security", "false");
logonDetails.Add("Locale Identifier", 1033);
logonDetails.Add("OLE DB Services", -5);
logonDetails.Add("Provider", "SQLOLEDB");
logonDetails.Add("Use Encryption for Data", 0);
//Create the QE (query engine) propertybag with the provider details and logon property bag.
CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag QE_Details = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();
QE_Details.Add("Database DLL", "crdb_ado.dll");
QE_Details.Add("QE_DatabaseName", db);
QE_Details.Add("QE_DatabaseType", "OLE DB (ADO)");
QE_Details.Add("QE_LogonProperties", logonDetails);
QE_Details.Add("QE_ServerDescription", server);
QE_Details.Add("QE_SQLDB", "True");
QE_Details.Add("SSO Enabled", "False");
CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo newConnInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo oldConnInfo;
CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfos oldConnInfos;
oldConnInfos = rcd.DatabaseController.GetConnectionInfos(null);
for (int I = 0; I < oldConnInfos.Count; I++)
{
oldConnInfo = oldConnInfos[I];
newConnInfo.Attributes = QE_Details;
newConnInfo.Kind = CrystalDecisions.ReportAppServer.DataDefModel.CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
try
{
rcd.DatabaseController.ReplaceConnection(oldConnInfo, newConnInfo, null, CrystalDecisions.ReportAppServer.DataDefModel.CrDBOptionsEnum.crDBOptionDoNotVerifyDB);
}
catch (Exception ex)
{
Label1.Text = ex.Message;
return;
}
}
doc.SetDatabaseLogon(user, pass);
To ensure that there is no login prompt at all at first I had to login to the controller and then set all the login credentials. Ensure that login credentials are reused during post back as well. After this is done, login using the reportdocument as well. This solves the issue of login prompt coming again and again.
Thanks
Shankar
Ok, here's the problem i've been dealing with the whole day:
I'm building a web application forms using WCF Data Service and XPO as ORM Data Model in the server side which contains a method, and in the client side, i'm trying to add a line to a database from a web form after authenfitication.
The user can log in without problems with this code:
try
{
ctx = null;
ctx = new XpoContext(serviceRootUri);
ctx.Credentials = new NetworkCredential(UserName.Text, UserPass.Text);
var res = ctx.Users.FirstOrDefault();
FormsAuthentication.RedirectFromLoginPage(UserName.Text, Persist.Checked);
}
catch (SecurityException ex)
{
Msg.Text = "Erreur: " + ex.Message;
}
}
now i want to add a line to a database with this code:
Uri u = new Uri(string.Format(LogIn.ctx.BaseUri + "/CreateUser?name='{0}'&pass='{1}'",
New_UserName.Text, New_UserPass.Text), UriKind.RelativeOrAbsolute);
LogIn.ctx.Execute(u, "GET");
ServiceReference1.Users user = new ServiceReference1.Users();
user.Nom = New_UserName.Text;
user.Pass = New_UserPass.Text;
LogIn.ctx.AddToUsers(user);
LogIn.ctx.SaveChanges();
but after executing in the 1st two lines an exception occurs.
i'm declaring my context as static in the logIn page:
private static Uri serviceRootUri = new Uri("http://localhost:28748/WcfDataService1.svc/");
public static XpoContext ctx;
As u can see i call my context in the adduser web form with LogIn.ctx ( the same context in the log in page )
Thanks
A production application in our organization uses Excel 2003 files to handle user submitted data through a web application. This application works reliably most of the time. Recently, the application has begun intermittently throwing "System.Data.OleDb.OleDbException: Unspecified error" when the OleDbConnection.Open() method is called. The error continues until the application pool is recycled, at which time everything functions as expected again. No errors are captured within the Windows Application event log.
The ASP.NET web application is hosted within web parts in WSS 3.0 on a Windows Server 2003 32 bit machine. The application is designed to prevent any concurrency issues. The system functional id is the only account with access to the temporary file store and there are mechanisms built in to ensure that the file cannot be overwritten by another upload during processing using a unique naming convention and upload tracking sub-system.
Any insight would be much appreciated.
We are using the following code to retrieve data from an Excel 2003 file:
public static DataTable GetWorksheetData(string filePath)
{
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder { DataSource = filePath };
builder.Provider = "Microsoft.Jet.OLEDB.4.0";
builder["Extended Properties"] = "Excel 8.0;IMEX=1;HDR=YES";
DataTable table = new DataTable();
try
{
// Creates an OleDbConnection for the excel file
using (OleDbConnection connection = new OleDbConnection(builder.ConnectionString))
{
connection.Open();
string sheetName = GetWorksheet(connection, "Template");
if (!string.IsNullOrEmpty(sheetName))
{
using (OleDbCommand command = connection.CreateCommand())
{
try
{
command.CommandText = string.Format("SELECT * FROM [{0}]", sheetName);
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
using (DataSet dataSet = new DataSet())
{
adapter.Fill(dataSet);
table = dataSet.Tables[0];
}
}
finally
{
connection.Close();
}
}
}
else
{
throw new InvalidWorksheetException();
}
}
}
catch (Exception ex)
{
Logger.Write(LogMsgSeverity.Error, ex);
throw;
}
return table;
}
private static string GetWorksheet(OleDbConnection connection, string sheetName)
{
string validSheetName = string.Empty;
using (DataTable tables = connection.GetSchema("Tables"))
{
DataRowCollection rows = tables.Rows;
if (rows.Count > 0)
{
foreach (DataRow row in rows)
{
if (row["Table_Name"].ToString().Contains(sheetName))
{
validSheetName = sheetName;
}
}
}
}
return validSheetName;
}
Actually what I needed was a step by step guide but anyway..
I have to show some rdl reports in a web-site using the ASP.NET report vievew and do all the necessary configurations for the Reporting Services. The users of the page should not deal with ANY authorization.
Here is my code for the report viewer:
rprtView.ServerReport.ReportServerCredentials = new ReportServerCredentials();
rprtView.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rprtView.ServerReport.ReportServerUrl = new Uri(#"http://mydomain/reports");
rprtView.ServerReport.ReportPath = #"/MyReports/PurchaseOrder";
rprtView.ShowParameterPrompts = false;
ReportParameter[] parameters = new ReportParameter[1];
parameters[0] = new ReportParameter();
parameters[0].Name = "OrderNumber";
parameters[0].Values.Add(orderNumber);
rprtView.ServerReport.SetParameters(parameters);
rprtView.ServerReport.Refresh();
Here is my overload for IReportServerCredentials
public class ReportServerCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = password = authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get { return new NetworkCredential("myUserName", "myPassword"); }
}
}
I am able to login to "http://mydomain/reports", the default web site of the SSRS, using "myUserName" and "myPassword" (I am not sure if this is related). Still I am getting MissingEndPoint exception at SetParameters() method above. It says:
"The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version."
I am also responsible for configuring the Reporting Services for the necessary configuration for this scenario and I have heard that this issue is related to the config files in SSRS but I have no idea what to write in them. Any help is much appreciated!
The string provided for rprtView.ServerReport.ReportServerUrl should be for the Report Server service, not the Report Manager application.
Change this:
rprtView.ServerReport.ReportServerUrl = new Uri(#"http://mydomain/reports");
to this:
rprtView.ServerReport.ReportServerUrl = new Uri(#"http://mydomain/reportserver");
This page has some high-level info on the Report Manager interface, Report Server web service, and how they relate.