Prompts Login window in Crystal Report in ASP.NET - mysql

I am using VS 2012
MySql
mysql-connector-odbc-5.3.4-win32.msi
4.crystal report runtime on windows server 2008.
My web application works fine in my development system, but after deployment to Windows server 2008 , crystal reports ask for addition information about login information as given in following screen.
using the following code.
string databaseName = "hr";
string serverName = "192.168.137.6";
string userID = "co";
string pass = "password";
protected void btn_search_Click(object sender, EventArgs e)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
TableLogOnInfo TabLogOnInfo = new TableLogOnInfo();
TableLogOnInfos TabInfos = new TableLogOnInfos();
ConnectionInfo conInfo = new ConnectionInfo();
string reportPath = Server.MapPath(#"~/GeneralEmpReports/ddoWiseEmpRpt.rpt");
string ddoCode = tbx_ddoCode.Text.ToUpper();
reportDocument.Load(reportPath);
reportDocument.SetParameterValue("D", ddoCode);
conInfo.ServerName = serverName;
conInfo.DatabaseName = databaseName;
conInfo.UserID = userID;
conInfo.Password = pass;
conInfo.AllowCustomConnection = false;
conInfo.IntegratedSecurity = false;
foreach (CrystalDecisions.CrystalReports.Engine.Table T in reportDocument.Database.Tables)
{
TabLogOnInfo = T.LogOnInfo;
TabLogOnInfo.ConnectionInfo = conInfo;
T.ApplyLogOnInfo(TabLogOnInfo);
}
CrystalReportViewer1.ReportSource = reportDocument;
CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
CrystalReportViewer1.AutoDataBind = true;
CrystalReportViewer1.Zoom(80);
}
i don't know how to solve the issue.

Related

Unable to use prefab login controls in Visual Studio

I'm using the Login box from the toolbox in visual studio. All the formats and such are already built-in, like the login boxes and password box, etc. But for some reason, I cannot get if (Convert.ToInt32(obj) != 0) to return anything but 0, unless I manually replace the #username and #password with 123 and 5551212 into the SQL string.
protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
{
using (MySqlConnection con = new MySqlConnection(strcon))
{
string UserName = Login.UserName;
string Password = Login.Password;
str = "select count(*) from users where username=#username and userpassword=#userpassword";
com = new MySqlCommand(str, con);
com.CommandType = CommandType.Text;
com.Parameters.Add("#username", MySqlDbType.VarChar).Value = UserName;
com.Parameters.Add("#userpassword", MySqlDbType.VarChar).Value = Password;
try
{
con.Open();
obj = com.ExecuteScalar();
if (Convert.ToInt32(obj) != 0)
{
Response.Redirect("Welcome.aspx");
}
else
{
Login.PasswordRequiredErrorMessage = "invalid user name and password";
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
con.Close();
}
}
Since
obj = com.ExecuteScalar();
if (Convert.ToInt32(obj) != 0)
Always gives me an obj of 0, I can never log in. But, as I said above, if I change the variables in the SQL string to the correct numbers for login and password, count is returned as 1, and then I can login.
Help appreciated! I'm not sure what Im missing. Using MySQL, or more specifically, MariaDB.

How do I customize the name of a report in SSRS 2016 to be output?

I want to export a paginated report from SSRS 2016 with a custom name from code. I can do it if I use the old 2005 control, but when I use the new URL access it either prompts me (if I'm in Edge) but defaults to the name of the report or in Chrome it just downloads with no prompting.
The report name, for example, is MyTestReport with several parameters passed to it. I'd like to be able to use those parameters to set the filename.
http://localhost/ReportServer/Pages/ReportViewer.aspx?/Finance/MyTestReport&i_entityID=98&i_sy=2016&i_runType=3&i_isPreview=true&rs:Format=PDF
That URL would ideally create a filename of 2016_Preview_Report.pdf if possible. I've searched through the SSRS documentation but can't find anything on how to go about doing so. A section of the code I'm using to export to PDF using the old 2005 control is below:
IReportServerCredentials irsc = new CustomReportCredentials(userid, password, domain);
var parametersCollection = new List<ReportParameter>();
parametersCollection.Add(new ReportParameter("i_sy", SY.ToString(), false));
parametersCollection.Add(new ReportParameter("i_entityID", LEA.ToString(), false));
parametersCollection.Add(new ReportParameter("i_runType", runtype.ToString(), false));
parametersCollection.Add(new ReportParameter("i_isPreview", isPreview.ToString(), false));
ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
rv.ProcessingMode = ProcessingMode.Remote;
rv.ServerReport.ReportServerCredentials = irsc;
rv.ServerReport.ReportPath = REPORT_PATH;
rv.ServerReport.ReportServerUrl = new Uri(SSRS_REPORT_SERVER);
rv.ServerReport.SetParameters(parametersCollection);
rv.ServerReport.Refresh();
byte[] streamBytes = null;
string mimeType = "";
string encoding = "";
string filenameExtension = "PDF";
string[] streamids = null;
Warning[] warnings = null;
FileContentResult ReturnFile = null;
filenameExtension = ExportType;
mimeType = "application/pdf";
streamBytes = rv.ServerReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
ReturnFile = File(streamBytes, mimeType, filename + "."+filenameExtension);
return ReturnFile;
This is how I did it:
public ActionResult GetPDFReport(int? id)
{
string filename = "Generate Filename Here"
NetworkCredential nwc = new NetworkCredential("username", "password");
WebClient client = new WebClient();
client.Credentials = nwc;
string reportURL = "http://servername//ReportServer?PO&rs:Format=PDF&rs:ClearSession=true&Param1=" + id;
return File(client.DownloadData(reportURL), "application/pdf", filename);
}

Quartz.net windows service does not execute job which referencesSSRS web service

I have used two web references of ssrs reporting execution service to generate the report. I am using quartz.net windows service for scheduling ssrs reports. My Windows service is working when I use the StdSchedulerFactory.GetDefaultScheduler() but as I execute my job in a Quartz service remotely and use GetScheduler() , it's not working.
public void Execute(IJobExecutionContext context)
{
RS2005.ReportingService2005 rs;
RE2005.ReportExecutionService rsExec;
// Create a new proxy to the web service
rs = new RS2005.ReportingService2005();
rsExec = new RE2005.ReportExecutionService();
// Authenticate to the Web service using Windows credentials
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://127.0.0.1:7001/ReportServer/reportservice2005.asmx";
rsExec.Url = "http://127.0.0.1:7001/ReportServer/reportexecution2005.asmx";
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
RE2005.Warning[] warnings = null;
string[] streamIDs = null;
// Path of the Report - XLS, PDF etc.
string fileName = "samplereport.pdf";
// Name of the report - Please note this is not the RDL file.
string _reportName = #"/reports_Debug/reportname";
string _historyID = null;
bool _forRendering = false;
RS2005.ParameterValue[] _values = null;
RS2005.DataSourceCredentials[] _credentials = null;
RS2005.ReportParameter[] _parameters = null;
try
{
_parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
RE2005.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID);
RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[8];
if (_parameters.Length > 0)
{
parameters[0] = new RE2005.ParameterValue();
parameters[0].Name = "FromDate";
parameters[0].Value = "1/1/2016";
parameters[1] = new RE2005.ParameterValue();
parameters[1].Name = "ToDate";
parameters[1].Value = "1/21/2016"; // June
}
rsExec.SetExecutionParameters(parameters, "en-us");
results = rsExec.Render(format, deviceInfo,
out extension, out encoding,
out mimeType, out warnings, out streamIDs);
using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
}
}
catch (Exception ex)
{
throw ex;
}
}

SSRS:The underlying connection was closed

I have a problem when viewing SSRS.
The error occurs add line reportViewer1.ServerReport.SetParameters(parm); when I call GenerateReport() to view the report in C# win-form progarm.
Error : The underlying connection was closed. An unexpected error occurred on a receive.
It was fine when I view the report through //local_host/ReportServer on I.E address bar.
I’m uing MS Studio 2008, SQL Server 2008
Thanks.
public void GenerateReport(DateTime fromdate, DateTime todate, float dauky, float psls, DateTime kybc)
{
ReportParameter[] parm = new ReportParameter[5];
parm[0] = new ReportParameter("fromdate", fromdate.ToShortDateString());
parm[1] = new ReportParameter("todate", todate.ToShortDateString());
parm[2] = new ReportParameter("kybc", kybc.ToString());
parm[3] = new ReportParameter("psls", psls.ToString());
parm[4] = new ReportParameter("dauky", dauky.ToString());
this.reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new System.Net.NetworkCredential("username", "pass", "domain");
reportViewer1.ShowCredentialPrompts = true;
reportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://localhost:80/ReportServer");
reportViewer1.ServerReport.ReportPath = "/Report Project1/TEST";
reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
reportViewer1.ServerReport.SetParameters(parm); //error occurs
reportViewer1.ServerReport.Refresh();
}

How TransactionScope works with DTC and WCF?

I have WCF Service with following coding:
using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
{
security = new Security(GetConnection(SecurityConstants.DatabaseName));
int userExists = security.UserRegistered(UserID,Pass);
transScope.Complete();
}
I have same method in DBA layer to run query by IExecuteResult as you can see here:
[Function(Name = SecurityConstants.SP_Name)]
public UserRegistered<IntegerOutput> IsUserExist(
[Parameter(Name = "USERID", DbType = "VarChar(15)")] string userID,
[Parameter(Name = "pass", DbType = "VarChar(25)")] string pass
)
{
IExecuteResult result = this.ExecuteMethodCall(this,((MethodInfo) (MethodInfo.GetCurrentMethod())), userID, pass);
return ((ISingleResult<IntegerOutput>)(result.ReturnValue));
}
Furthermore, I have checked MSDTC's configuration, but when I run my application it face to "Communication with the underlying transaction manager has failed" error. I have enabled DTC on my local machine and server side, but I still have problem. could you let me know is it for network setting or my local mochine or something else? could you please help me.