本文整理汇总了C#中ReportDocument.SetDatabaseLogon方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.SetDatabaseLogon方法的具体用法?C# ReportDocument.SetDatabaseLogon怎么用?C# ReportDocument.SetDatabaseLogon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReportDocument
的用法示例。
在下文中一共展示了ReportDocument.SetDatabaseLogon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnPrint_Click
protected void btnPrint_Click(object sender, EventArgs e)
{
ReportDocument crystalReport = new ReportDocument();
if (ddlExamination.SelectedIndex == 1)
{
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/BestALResults.rpt"));
}
else if (ddlExamination.SelectedIndex == 2)
{
crystalReport.Load(Server.MapPath("Reports/BestALResults.rpt"));
}
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");
//Provide parameter values
crystalReport.SetParameterValue("year", int.Parse(ddlYear.SelectedValue.ToString()));
crystalReport.PrintToPrinter(1, true, 1, 2);
}
示例2: GenerateReport
protected void GenerateReport()
{
System.Console.Beep();
//Create report document
ReportDocument crystalReport = new ReportDocument();
if (txtStart.Text != "" && txtEnd.Text != "" )
{
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/Notifications.rpt"));
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");
//Provide parameter values
crystalReport.SetParameterValue("start", txtStart.Text.ToString());
crystalReport.SetParameterValue("end", txtEnd.Text.ToString());
//Set Report in to Report Viewer
crvReportViewer.ReportSource = crystalReport;
}
else
{
// lblError.ForeColor = Color.Red;
// lblError.Text = "Please Provide Valid Details";
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["uname"].ToString();
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("SoldProduct.rpt"));
/* ParameterFieldDefinitions PFDS;
ParameterFieldDefinition PFD;
ParameterValues PVS = new ParameterValues();
ParameterDiscreteValue PDV = new ParameterDiscreteValue();
PVS.Clear();
PDV.Value = "";
PFDS = cryRpt.DataDefinition.ParameterFields;
PFD = PFDS["@sDate"];
PVS = PFD.CurrentValues;
//
PVS.Add(PDV);
PFD.ApplyCurrentValues(PVS);
PDV.Value = "";
PFDS = cryRpt.DataDefinition.ParameterFields;
PFD = PFDS["@eDate"];
PVS = PFD.CurrentValues;
//PVS.Clear();
PVS.Add(PDV);
PFD.ApplyCurrentValues(PVS);*/
cryRpt.SetDatabaseLogon("sa", "123", "server", "auction");
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
}
示例4: cmdExportarExcel_Click
protected void cmdExportarExcel_Click(object sender, EventArgs e)
{
String regionCodigo = txtRegionCodigo.Text;
String zonaCodigo = txtZonaCodigo.Text;
try
{
String db_databaseName = connectionBL.getDataBaseName();
String db_serverName = connectionBL.getServerName();
String db_userID = connectionBL.getUserID();
String db_password = connectionBL.getPassword();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("../CrystalReports/crReporteSeguimiento.rpt"));
rpt.SetDatabaseLogon("", "", ".", db_databaseName);
rpt.SetParameterValue("@regionCodigo", regionCodigo);
rpt.SetParameterValue("@zonaCodigo", zonaCodigo);
rpt.SetParameterValue("@estadoVerificiado", Convert.DBNull);
rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Reporte_seguimientos_" + DateFormatter.getTimestamp(DateTime.Now));
/*
rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Prueba_ExcelNormal");
//rpt.ExportToHttpResponse(ExportFormatType.ExcelRecord, Response, true, "Prueba_ExcelRecord");
*/
}
catch (Exception ex)
{
//System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
String qs = Request.QueryString.Get("bid");
Response.Write("Query String = " + qs);
SqlConnection sql = new SqlConnection();
sql.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
sql.Open();
ReportDocument rpd = new ReportDocument();
rpd.Load(Server.MapPath("itcreport.rpt"));
rpd.SetDatabaseLogon("sa", "ak");
rpd.SetParameterValue(0, qs);
CrystalReportViewer1.ReportSource = rpd;
//to convert report in pdf format
MemoryStream ostream = new MemoryStream();
Response.Clear();
Response.Buffer = true;
ostream = (MemoryStream)rpd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
rpd.Close();
rpd.Dispose();
Response.ContentType = "application/pdf";
Response.BinaryWrite(ostream.ToArray());
ostream.Flush();
ostream.Close();
ostream.Dispose();
}
示例6: ReportTitle
private string ReportTitle(string reportFile)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(reportFile);
rpt.SetDatabaseLogon(DataInterface.Config.DefaultUserName, DataInterface.Config.DefaultPassword, DataInterface.Config.DefaultServerName, DataInterface.Config.DefaultDatabaseName);
return rpt.SummaryInfo.ReportTitle;
//rpt.SetParameterValue("pkWorkDay", this._pkWorkDay);
//string tempDir = config.ReportFolder + @"TempExport\";
//Directory.CreateDirectory(tempDir);
//foreach (string tempFile in Directory.GetFiles(tempDir))
//{
// try
// {
// File.Delete(tempFile);
// }
// catch
// {
// }
//}
//string tempPdf = tempDir + Guid.NewGuid().ToString() + ".xls";
//rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, tempPdf);
}
示例7: btnExecute_Click
private void btnExecute_Click(object sender, EventArgs e)
{
ReportDocument report = new ReportDocument();
report.Load(this.filePath);
report.SetDatabaseLogon(userName, password, server, db);
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
//order no
crParameterDiscreteValue.Value = txtFilter.Text;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["orderNo"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
//start date
crParameterDiscreteValue.Value = dtpStartDate.Value;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["startDate"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
//end date
crParameterDiscreteValue.Value = dtpEndDate.Value;
crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["endDate"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = server;
crConnectionInfo.DatabaseName = db;
crConnectionInfo.UserID = userName;
crConnectionInfo.Password = password;
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = crConnectionInfo;
TableLogOnInfos logOnInfos = new TableLogOnInfos();
logOnInfos.Add(logOnInfo);
crystalReportViewer.LogOnInfo = logOnInfos;
crystalReportViewer.ReportSource = report;
crystalReportViewer.Refresh();
}
示例8: ddlYear_SelectedIndexChanged
protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e)
{
//If Required Fields is not Selected Display Error
if (ddlCategory.SelectedIndex == 0)
{
lblError.ForeColor = Color.Red; //Change Label Color
lblError.Text = "Please Select a Valid Category"; //Set Error
}
else if (ddlYear.SelectedIndex == 0)
{
lblError.ForeColor = Color.Red;
lblError.Text = "Please Select a Valid Year";
}
else
{
lblError.Text = ""; //After Fixing error hide the Error Message
if (ddlCategory.SelectedIndex == 1)
{
//Create report document
ReportDocument crystalReport = new ReportDocument();
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/StudentAdmissionReport.rpt"));
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");
//Provide parameter values
crystalReport.SetParameterValue("year", int.Parse(ddlYear.SelectedValue.ToString()));
//Set Report in to Report Viewer
crvReportViewer.ReportSource = crystalReport;
}
else if (ddlCategory.SelectedIndex == 2)
{
//Create report document
ReportDocument crystalReport = new ReportDocument();
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/StudentLeavingReport.rpt"));
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");
//Provide parameter values
crystalReport.SetParameterValue("year", int.Parse(ddlYear.SelectedValue.ToString()));
crvReportViewer.ReportSource = crystalReport;
}
else
{
lblError.ForeColor = Color.Red;
lblError.Text = "Please Provide Valid Details";
}
}
}
示例9: Pedidoxcliente
public ActionResult Pedidoxcliente(int idCliente,string fecha1,string fecha2)
{
SqlConnection con = new SqlConnection("server=.;database=bdpastelelias;UID=sa;PWD=sql");
DataTable dt = new DataTable();
DateTime fec1 = Convert.ToDateTime(fecha1);
DateTime fec2 = Convert.ToDateTime(fecha2);
try
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT pe.idpedido,pro.idproducto,pro.nomProducto,pp.precio,pp.cantidad,pp.total,pe.contacto_nom,pe.contacto_ape,pe.contacto_mail,contacto_movil,pe.fechaPedido,pe.fechaentrega,pe.entrega_dir,pe.subTotal,pe.igv,pe.totalpedido,c.nombre as Cliente,d.descrip as Distrito,tc.descrip as 'Comprobante',tp.descrip as 'Tipo Pago',e.descrip as Estado FROM pedido pe inner join Cliente c on pe.idCliente=c.idCliente inner join distrito d on pe.iddistrito=d.iddistrito inner join tipo_compPago tc on pe.idtipo_compPago=tc.idtipo_compPago inner join TIPO_PAGO tp on pe.idtipopago=tp.idtipopago inner join estado e on pe.idestado=e.idestado inner join pedido_productos pp on pe.idpedido=pp.idpedido inner join producto pro on pp.idproducto=pro.idproducto", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
catch (Exception ex)
{
}
ReportDocument rpt = new ReportDocument();
// ReportClass rpt = new ReportClass();
// rpt.FileName = Server.MapPath("/Reportes/rptPedidos4.rpt");
rpt.Load(Path.Combine(Server.MapPath("~/Reportes"), "rptPedidos4.rpt"));
rpt.SetDatabaseLogon("sa", "sql");
// rpt.Load();
// rpt.SetDataSource(dt);
// rpt.SetDataSource(from pe in storeDB.pedido
// join c in storeDB.Cliente on pe.idCliente equals c.idCliente
// join d in storeDB.distrito on pe.iddistrito equals d.iddistrito
// join tc in storeDB.tipo_compPago on pe.idtipo_compPago equals tc.idtipo_compPago
// join tp in storeDB.TIPO_PAGO on pe.idtipopago equals tp.idtipopago
// join e in storeDB.estado on pe.idestado equals e.idestado
// join pp in storeDB.pedido_productos on pe.idpedido equals pp.idpedido
// join pro in storeDB.producto on pp.idproducto equals pro.idproducto
// select new {pe.idpedido,pro.idproducto,pro.nomProducto,pp.precio,pp.cantidad,pp.total,pe.contacto_nom,pe.contacto_ape,pe.contacto_mail,pe.contacto_movil,pe.fechaPedido,pe.fechaentrega,pe.entrega_dir,pe.subTotal,pe.igv,pe.totalpedido,Cliente=c.nombre,Distrito=d.descrip,Comprobante=tc.descrip,Tipo_Pago=tp.descrip,Estado=e.descrip});
// ParameterDiscreteValue idCli = new ParameterDiscreteValue();
// idCli.Value = idCliente;
// ParameterDiscreteValue fe1 = new ParameterDiscreteValue();
// fe1.Value = fecha1;
// ParameterDiscreteValue fe2 = new ParameterDiscreteValue();
// fe2.Value = fecha2;
rpt.SetParameterValue("@idCliente", idCliente);
rpt.SetParameterValue("@fecha1", fecha1);
rpt.SetParameterValue("@fecha2", fecha2);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf","ReporteDeClientes.pdf");
}
示例10: CategoriaxProducto1
public ActionResult CategoriaxProducto1(int idcategoriaProd)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Path.Combine(Server.MapPath("~/Reportes"), "rptProductoxCategoria.rpt"));
rpt.SetDatabaseLogon("sa", "sql");
rpt.SetParameterValue("@idcategoriaProd", idcategoriaProd);
return new pdfToCrystalReport(rpt);
}
示例11: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Path.Combine(Server.MapPath("~/Reportes"), "rptPedidos4.rpt"));
rpt.SetDatabaseLogon("sa", "sql");
rpt.SetParameterValue("@idCliente", 1);
rpt.SetParameterValue("@fecha1", "23/06/2015");
rpt.SetParameterValue("@fecha2", "29/06/2015");
crvClientes.ReportSource = rpt;
crvClientes.DataBind();
}
示例12: PrintReceipt
public static void PrintReceipt(string salesOrderNo)
{
try
{
string receiptPath = factory.MasterDataBroker.GetReceiptPath();
if (string.IsNullOrEmpty(receiptPath))
return;
ReportDocument receipt = new ReportDocument();
receipt.Load(receiptPath);
string conString = BMResto.BO.General.ConnectionHelper.BMRestoConnectionString;
string[] conStringDetails = conString.Split(';');
string server = conStringDetails.SingleOrDefault(o => o.Contains("Data Source")).Split('=')[1];
string db = conStringDetails.SingleOrDefault(o => o.Contains("Initial Catalog")).Split('=')[1];
string userName = conStringDetails.SingleOrDefault(o => o.Contains("User ID")).Split('=')[1];
string password = conStringDetails.SingleOrDefault(o => o.Contains("Password")).Split('=')[1];
receipt.SetDatabaseLogon(userName, password, server, db);
foreach (CrystalDecisions.CrystalReports.Engine.Table table in receipt.Database.Tables)
{
TableLogOnInfo logOnInfo = table.LogOnInfo;
if (logOnInfo != null)
{
logOnInfo.TableName = table.Name;
logOnInfo.ConnectionInfo.DatabaseName = db;
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.UserID = userName;
logOnInfo.ConnectionInfo.ServerName = server;
table.ApplyLogOnInfo(logOnInfo);
}
}
// order no
ParameterDiscreteValue pfDiscrete = new CrystalDecisions.Shared.ParameterDiscreteValue();
pfDiscrete.Value = salesOrderNo;
SetParameterValue("orderNo", receipt, pfDiscrete);
// cashier
ParameterDiscreteValue pfCashier = new CrystalDecisions.Shared.ParameterDiscreteValue();
pfCashier.Value = MembershipHelper.CurrentUserName;
SetParameterValue("cashier", receipt, pfCashier);
receipt.PrintToPrinter(1, false, 0, 1);
}
catch
{
throw;
}
}
示例13: ShowReport
public void ShowReport(string reportFile)
{
_reportFile = reportFile;
_reportDoc = new ReportDocument();
_reportDoc.Load(_reportFile);
_reportDoc.SetDatabaseLogon(DataInterface.Config.DefaultUserName, DataInterface.Config.DefaultPassword, DataInterface.Config.DefaultServerName, DataInterface.Config.DefaultDatabaseName);
//this.SetBuildProjectParameter();
if (_reportDoc.SummaryInfo != null
&& _reportDoc.SummaryInfo.ReportTitle != null
&& _reportDoc.SummaryInfo.ReportTitle.Trim().Length > 0)
this.Text = _reportDoc.SummaryInfo.ReportTitle;
//this.ucParam.LoadParameters(_reportDoc);
this.LoadViewer();
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//txtUser.Text = Session["user"].ToString();
//Create report document
ReportDocument crystalReport = new ReportDocument();
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/ParentCategory.rpt"));
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");
crvReportViewer.ReportSource = crystalReport;
}
示例15: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
int id = 5;
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("crBaoCao.rpt"));
rptDoc.SetDatabaseLogon("sa", "sql2008", "10.21.0.112\\SQL2005", "BanTTAT");
rptDoc.SetParameterValue("baocaoid", id);
CrystalReportViewer1.ReportSource = rptDoc;
}
catch { }
}