private async Task GetDatAnswerAsync(long getAnswerID) { document = new ReportDocument(); document.Load(Server.MapPath("../Admin/Report/ReportUser.rpt")); document.SetParameterValue("p_NoUrut", getAnswerID); document.SetDataSource(await GetInteviewerDetailAsync(getAnswerID)); ReportViewerUser.ReportSource = document; ReportViewerUser.DataBind(); }
private void LoadReportDocument(long answerID) { try { ParameterFields paramfields = new ParameterFields(); //collection of parameters ParameterField paramfield = new ParameterField(); //your parameter ParameterDiscreteValue dsvalue = new ParameterDiscreteValue(); // holder of your the value for the parameter TableLogOnInfo tableLogOnInfo = new TableLogOnInfo(); document = new ReportDocument(); using (MySqlConnection conn = ServicesConfig.DatabaseService.Connection()) { mySqlCommand = new MySqlCommand(); mySqlCommand.Connection = conn; mySqlCommand.CommandText = "spINFINET_GetAnswersUser"; mySqlCommand.CommandType = CommandType.StoredProcedure; mySqlCommand.CommandTimeout = 60; mySqlCommand.Parameters.AddWithValue("p_AnswersID", answerID); dataAdapter = new MySqlDataAdapter(); dataAdapter.SelectCommand = mySqlCommand; DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "spINFINET_GetAnswersUser"); paramfield.Name = "p_NomorUrut"; dsvalue.Value = Convert.ToInt64(Session["ThrowAdnswerID"].ToString()); paramfield.CurrentValues.Add(dsvalue); paramfield.HasCurrentValue = true; paramfields.Add(paramfield); document.Load(Server.MapPath("../Admin/Report/ReportViewerUser.rpt")); document.SetDataSource(dataSet); ReportViewerUser.ParameterFieldInfo.Add(paramfield); ReportViewerUser.EnableParameterPrompt = false; ReportViewerUser.EnableDatabaseLogonPrompt = false; connectionInfo.ServerName = "127.0.0.1"; connectionInfo.DatabaseName = "opsonlinetest"; connectionInfo.UserID = "infinet"; connectionInfo.Password = "******"; Tables tables = (Tables)document.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables) { tableLogOnInfo = table.LogOnInfo; tableLogOnInfo.ConnectionInfo = connectionInfo; table.ApplyLogOnInfo(tableLogOnInfo); } ReportViewerUser.ReportSource = document; ReportViewerUser.DataBind(); document.VerifyDatabase(); Session["ReportDocument"] = document; document.Refresh(); if (conn.State == ConnectionState.Open) { conn.Close(); } } } catch (MySqlException myEx) { System.Text.StringBuilder stringBuilder = PageUtility.MessageBox("Error", myEx.Message, "error"); ClientScript.RegisterStartupScript(Page.GetType(), "alertMessageError", stringBuilder.ToString()); } catch (Exception Ex) { System.Text.StringBuilder stringBuilder = PageUtility.MessageBox("Error", Ex.Message, "error"); ClientScript.RegisterStartupScript(Page.GetType(), "alertMessageError", stringBuilder.ToString()); } }