コード例 #1
0
        ConnectionObject CreateConnection()
        {
            var conobj = ConnectionObject.CreateInstance(this.model.ReportSettings.ConnectionString,
                                                         System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));

            conobj.QueryString = model.ReportSettings.CommandText;
            return(conobj);
        }
コード例 #2
0
 public static ConnectionObject BuildConnectionObject(ReportSettings reportSettings)
 {
     if (reportSettings == null)
     {
         throw new ArgumentNullException("reportSettings");
     }
     return(ConnectionObject.CreateInstance(reportSettings.ConnectionString,
                                            DbProviderFactories.GetFactory("System.Data.OleDb")));
 }
コード例 #3
0
        private DataSet FillGrid()
        {
            this.connectionObject = ConnectionObject.CreateInstance(this.model.ReportSettings.ConnectionString,
                                                                    System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));

            this.txtSqlString.Text = String.Empty;
            SqlQueryChecker.Check(model.ReportSettings.CommandType,
                                  model.ReportSettings.CommandText);
            DataSet dataSet = ResultPanel.CreateDataSet();


            switch (model.ReportSettings.CommandType)
            {
            case CommandType.Text:
                this.txtSqlString.Text = model.ReportSettings.CommandText;
                dataSet = BuildFromSqlString();
                break;

            case CommandType.StoredProcedure:
                MessageService.ShowError("Stored Procedures are not suppurted at the moment");
                break;

            case CommandType.TableDirect:
                MessageService.ShowError("TableDirect is not suppurted at the moment");
                break;

            default:
                throw new Exception("Invalid value for CommandType");
            }


            if (model.ReportSettings.CommandType == CommandType.StoredProcedure)
            {
                /*
                 * if (reportStructure.SharpQueryProcedure == null) {
                 *      throw new IllegalQueryException();
                 * }
                 *
                 * SharpQueryProcedure procedure = reportStructure.SharpQueryProcedure;
                 * SharpQuerySchemaClassCollection sc = procedure.GetSchemaParameters();
                 *
                 * if ((sc != null) && sc.Count > 0) {
                 *      dataSet = ExecuteStoredProc (procedure);
                 * }else {
                 *      dataSet = ExecuteStoredProc ();
                 * }
                 */
            }

            // from here we create from an SqlString like "Select...."
//			if (model.ReportSettings.CommandType == CommandType.Text){
//				this.txtSqlString.Text = model.ReportSettings.CommandText;
//				dataSet = BuildFromSqlString();
//			}
            return(dataSet);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: kleinux/SharpDevelop
        private void RunProviderIndependent(string reportName)
        {
            string           conOleDbString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SharpReport_TestReports\TestReports\Nordwind.mdb;Persist Security Info=False";
            ReportParameters parameters     = ReportEngine.LoadParameters(reportName);
            ConnectionObject con            = ConnectionObject.CreateInstance(conOleDbString,
                                                                              System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));

            parameters.ConnectionObject = con;
            parameters.SqlParameters[0].ParameterValue = "Provider Independent";
            this.previewControl1.PreviewLayoutChanged += delegate(object sender, EventArgs e)
            {
                this.RunProviderIndependent(reportName);
            };
            this.previewControl1.RunReport(reportName, parameters);
        }
コード例 #5
0
ファイル: ResultPanel.cs プロジェクト: prid77/TickZoomPublic
        private DataSet FillGrid()
        {
            this.connectionObject = ConnectionObject.CreateInstance(this.model.ReportSettings.ConnectionString,
                                                                    System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));

            this.txtSqlString.Text = String.Empty;
            SqlQueryChecker.Check(model.ReportSettings.CommandType,
                                  model.ReportSettings.CommandText);
            DataSet dataSet = ResultPanel.CreateDataSet();

            this.txtSqlString.Text = model.ReportSettings.CommandText;
            if (model.ReportSettings.CommandType == CommandType.StoredProcedure)
            {
                if (reportStructure.SharpQueryProcedure == null)
                {
                    throw new IllegalQueryException();
                }

                SharpQueryProcedure             procedure = reportStructure.SharpQueryProcedure;
                SharpQuerySchemaClassCollection sc        = procedure.GetSchemaParameters();

                if ((sc != null) && sc.Count > 0)
                {
                    dataSet = ExecuteStoredProc(procedure);
                }
                else
                {
                    dataSet = ExecuteStoredProc();
                }
            }

            // from here we create from an SqlString like "Select...."
            if (model.ReportSettings.CommandType == CommandType.Text)
            {
                this.txtSqlString.Text = model.ReportSettings.CommandText;
                dataSet = BuildFromSqlString();
            }
            return(dataSet);
        }