using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using MySql.Data.MySqlClient; using System.Data; using System.IO; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; namespace dbdates { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { ReportDocument rptDoc = new ReportDocument(); DataSet2 ds = new DataSet2(); // .xsd file name DataTable dt = new DataTable(); dt.TableName = "Crystal Report Example"; dt = getAllOrders(); ds.Tables[0].Merge(dt); rptDoc.Load(Server.MapPath("CrystalReport4.rpt")); rptDoc.SetDataSource(ds); CrystalReportViewer1.ReportSource = rptDoc; } public DataTable getAllOrders() { string sqlCon = "Server=localhost; Database=vvv; User ID=root; Password=xxxx;"; MySqlConnection Con = new MySqlConnection(sqlCon); MySqlCommand cmd = new MySqlCommand(); DataSet dd = null; MySqlDataAdapter adapter; try { Con.Open(); cmd = Con.CreateCommand(); cmd = new MySqlCommand("SELECT ID, Name, Content FROM images ", Con); dd = new DataSet(); adapter = new MySqlDataAdapter(cmd); adapter.Fill(dd, "vvv"); } catch (Exception ex) { throw new Exception(ex.Message); } finally { cmd.Dispose(); if (Con.State != ConnectionState.Closed) Con.Close(); } return dd.Tables[0]; } } }
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="dbdates._Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Welcome to ASP.NET! </h2> <p> To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>. </p> <p> You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"> title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. </p> <asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click1" /> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)