Ejemplo n.º 1
0
		private DataSet ExecuteStoredProc (SharpQueryProcedure procedure)
		{
			
			SharpQuerySchemaClassCollection tmp = procedure.GetSchemaParameters();
			this.sqlParamsCollection = new ParameterCollection();
			SqlParameterConverter converter = new SqlParameterConverter();
			
			if (converter.CanConvertFrom(typeof(SharpQuerySchemaClassCollection))) {
				if (converter.CanConvertTo(null,typeof(ParameterCollection))){
					sqlParamsCollection = (ParameterCollection)converter.ConvertTo(null,
					                                                                   CultureInfo.InstalledUICulture,
					                                                                   tmp,
					                                                                   typeof(ParameterCollection));
				}
			}
			
			if (sqlParamsCollection.Count > 0){
				using (ParameterDialog inputform = new ParameterDialog(sqlParamsCollection)) {
					if ( inputform.ShowDialog() != DialogResult.OK ){
						return null;
					}
					else
					{
						IDbCommand command = this.BuildCommand();
						DbDataAdapter adapter = this.BuildAdapter();
						DataSet dataSet = ResultPanel.CreateDataSet();
						try {
							SqlDataAccessStrategy.BuildQueryParameters(command,sqlParamsCollection);
							adapter.SelectCommand = (DbCommand)command;
							
							adapter.Fill (dataSet);
							return dataSet;
						} catch (Exception e) {	
							MessageService.ShowError(e.Message);
						} finally {
							if (adapter.SelectCommand.Connection.State == ConnectionState.Open) {
								adapter.SelectCommand.Connection.Close();
							}
						}
					}
				}
			}
			return null;
		}
Ejemplo n.º 2
0
		protected  virtual void Dispose(bool disposing){
			if (disposing) {
				if (this.reportItemCollection != null) {
					this.reportItemCollection.Clear();
					this.reportItemCollection = null;
				}
				if (this.availableFieldsCollection != null) {
					this.availableFieldsCollection.Clear();
					this.availableFieldsCollection = null;
				}
				if (this.queryParameters != null) {
					this.queryParameters.Clear();
					this.queryParameters = null;
					
				}
				
				if (this.sharpQueryProcedure != null) {
					this.sharpQueryProcedure = null;
				}
				
			}
		
			// Release unmanaged resources.
			// Set large fields to null.
			// Call Dispose on your base class.
		}
		public SharpQueryNodeProcedure(SharpQueryProcedure sharpQueryProcedure)
			: base(sharpQueryProcedure)
		{
			this.ImageIndex = 8;
			this.SelectedImageIndex = 8;
		}