Esempio n. 1
0
        /// <summary>
        /// Illustrates using a GrapeCity SqlServer object as a data source.
        ///
        /// </summary>
        private void btnSqlServer_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            //Verify that a SQL Server has been selected
            if (cbSqlServerList.SelectedItem == null)
            {
                MessageBox.Show("Please select a SQL Server first.");
                Cursor = Cursors.Arrow;
                return;
            }
            //SqlServer Data Source object to use
            Data.SqlDBDataSource sql = new Data.SqlDBDataSource();

            //Assign the database connection string based on the SQL Server selected
            sql.ConnectionString = "Data Source=" + cbSqlServerList.SelectedItem + ";Initial Catalog=Northwind;Integrated Security=SSPI";
            //Run the SQL command.
            sql.SQL = "SELECT * FROM invoices ORDER BY CustomerID, OrderID";
            //Create the report and assign the data source.
            Invoice rpt = new Invoice();

            rpt.DataSource = sql;
            //Run and view the report
            try
            {
                arvMain.LoadDocument(rpt);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor = Cursors.Arrow;
        }
Esempio n. 2
0
        /// <summary>
        /// Illustrates using a GrapeCity SqlServer object as a data source.
        ///
        /// </summary>
        private void btnSqlServer_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            //Verify that a SQL Server has been selected
            //
            if (cbSqlServerList.SelectedItem == null)
            {
                MessageBox.Show(Properties.Resources.SelectSQLServer);
                Cursor = Cursors.Arrow;
                return;
            }

            //SqlServer Data Source object to use
            //
            Data.SqlDBDataSource sql = new Data.SqlDBDataSource();

            //Assign the database connection string based on the SQL Server selected
            //
            sql.ConnectionString = "Data Source=" + cbSqlServerList.SelectedItem + ";Initial Catalog=Northwind;Integrated Security=SSPI";
            //Run the SQL command.
            //
            sql.SQL = "SELECT * FROM invoices ORDER BY CustomerID, OrderID";

            //Create the report and assign the data source.
            //
            var rpt = new ActiveReports.SectionReport();

            rpt.LoadLayout(XmlReader.Create(System.IO.Path.Combine("..\\..\\", Properties.Resources.ReportName)));
            rpt.DataSource = sql;
            //Run and view the report
            //
            try
            {
                arvMain.LoadDocument(rpt);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }

            Cursor = Cursors.Arrow;
        }