Thursday, March 29, 2012

Edit a dataset

I want to query a set of tables in order to create a dataset that I can look
at (in a grid in my application) and decide manually whether I want to
include the records for further processing such as including in a report. I
thought to have a bit field which I can treat as a boolean value and then
check or uncheck it in my application. My tables do not contain the bit
field.
Is it possible to generate such a field in my query which can be edited
subseqently by the operator in the grid in the application? I have tried
this with a query, but am not allowed to edit a derived field.
Another thought was to create a temporary table to contain an ID and the bit
field. My original query would populate the temporary table with the ID and
my bit field would be set to 1 (true). After this I create my dataset by
linking my temporary table (via the ID) with my original main table. Then
there is no hindrance to my editing the bit field.
Is there a better way of doing this operation?
Thanks,
Steve.
> Is it possible to generate such a field in my query which can be edited
> subseqently by the operator in the grid in the application? I have tried
> this with a query, but am not allowed to edit a derived field.
I think you ought to be able to edit the derived value in your DataSet as
long as you don't try save the value to the database.

> Is there a better way of doing this operation?
One method is to add the selection option column to the DataTable after
loading the data. I think this sort of approach is better than returning
the GUI column from the SQL query. For example:
dataSet1.Tables["Table"].Columns.Add("Selected", typeof(bool));
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"Sawlmgsj" <Sawlmgsj@.discussions.microsoft.com> wrote in message
news:566D47D9-F29D-46F5-80D8-C148A40D6394@.microsoft.com...
>I want to query a set of tables in order to create a dataset that I can
>look
> at (in a grid in my application) and decide manually whether I want to
> include the records for further processing such as including in a report.
> I
> thought to have a bit field which I can treat as a boolean value and then
> check or uncheck it in my application. My tables do not contain the bit
> field.
> Is it possible to generate such a field in my query which can be edited
> subseqently by the operator in the grid in the application? I have tried
> this with a query, but am not allowed to edit a derived field.
> Another thought was to create a temporary table to contain an ID and the
> bit
> field. My original query would populate the temporary table with the ID
> and
> my bit field would be set to 1 (true). After this I create my dataset by
> linking my temporary table (via the ID) with my original main table. Then
> there is no hindrance to my editing the bit field.
> Is there a better way of doing this operation?
> Thanks,
> Steve.
|||Dan - many thanks.
I'll give that a try.
Regards,
Steve.
"Dan Guzman" wrote:

> I think you ought to be able to edit the derived value in your DataSet as
> long as you don't try save the value to the database.
>
> One method is to add the selection option column to the DataTable after
> loading the data. I think this sort of approach is better than returning
> the GUI column from the SQL query. For example:
> dataSet1.Tables["Table"].Columns.Add("Selected", typeof(bool));
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> http://weblogs.sqlteam.com/dang/
> "Sawlmgsj" <Sawlmgsj@.discussions.microsoft.com> wrote in message
> news:566D47D9-F29D-46F5-80D8-C148A40D6394@.microsoft.com...
>

No comments:

Post a Comment