Runtime editing of SelectCommand property
Hello,
I have added a datasource to my report and defined a query for it. I want to perform such a complex variations of the query that I need to be able to change the whole where clause of the query (parameters are not enough). I do not want to transfer all the rows the table contains via network and that is why I don't want to use Filter property of the databand.
So how can I assign the SelectCommand property of a table in startreport eventhandler (or elsewhere) to value of a report parameter?
I have added a datasource to my report and defined a query for it. I want to perform such a complex variations of the query that I need to be able to change the whole where clause of the query (parameters are not enough). I do not want to transfer all the rows the table contains via network and that is why I don't want to use Filter property of the databand.
So how can I assign the SelectCommand property of a table in startreport eventhandler (or elsewhere) to value of a report parameter?
Comments
Try this way:
You can do it inside the Report.StartReport event handler (either in the script or your C# code).
I get error "System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. at System.Data.DataSet.FailedEnableConstraints()"
In my query I join "units" to "events" so if one unit has multiple events then the result has multiple rows with same unit id what makes the error.
So how can I disable that primary key (and other) constraints from dataset? I have used the report designer to define these queries and I do not want that resulting datasets have any constraints.
If I right click my datatable object in the designer and choose "View Data..." on the first time I get error message:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
if I try the same again then I can view the data but there are these red marks in the cells where are same values. Tooltip of the marks says "Column unitID is constrained to be unique. Value '1234' is allready present."
Im not expert on datasets or visual studio, but for me it seems that you can reproduce it just by making query and making join so that it will result multiple rows of first tables primary key.
like:
SELECT unitID
FROM units JOIN events ON units.unitID = events.unit
Anyway now I got it working by just taking the "eventID" field to the query as the first field so that the first field is always unique. (Little bit strange "feature" but I just need my report working [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> ) One more question (again): I have put a one row table to a databand and I want that the cells of the table grow whenever one cell has so much data that it does not fit to it. I have set the "CanGrow" property of the table and databand to true but it does not work. Do I have to set some other properties also?[/img]
Select the table row and set its AutoSize property to true. You can do this in the row's context menu as well. The table itself does not use the CanGrow/CanShrink properties, so I'll hide them.
Now I get the following error everytime when I switch to page 2 in the report preview and when the table rows AutoSize property is true. When the AutoSize property is false then the error does not occur.
(In my report I have PageHeader, ColumnHeader, Data, Column Footer and Page Footer. Data contains the table that expands to two pages)
************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at FastReport.Table.TableRowCollection.get_Item(Int32 index)
at FastReport.Table.TableBase.IsVisible(FRPaintEventArgs e)
at FastReport.ReportPage.Draw(FRPaintEventArgs e)
at OEgLHQCnJP0SE8c59lA.OtwZyPC6aOjJDZUfvic.C5OA6W38d(Graphics , Boolean )
at OEgLHQCnJP0SE8c59lA.OtwZyPC6aOjJDZUfvic.OnPaint(PaintEventArgs )
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
*********************************************************************************