Home All Groups Group Topic Archive Search About

Query in memory dataset c# 2

Author
11 May 2007 7:46 PM
deciacco
Is there a way to query an in-memory dataset with sql or can you only
work with the individual table through DataTable.Select()?

How can you go about getting the identity of a new record if you use an
autoincrement primary key on the datatable?

Thanks

Author
11 May 2007 8:39 PM
William (Bill) Vaughn
Unless you have an in-memory SQL engine (like SQL Server Compact Edition)
all you can do is use the Select, Find etc. features of the
DataTable/DataView classes.

AFA retrieving the new Identity value an additional query needs to be
executed to execute SELECT @@Identity or (better yet) SCOPE_IDENTITY().

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Show quote
"deciacco" <a@a> wrote in message
news:jN2dnbx1v-ucVdnbnZ2dnUVZ_vOlnZ2d@giganews.com...
> Is there a way to query an in-memory dataset with sql or can you only work
> with the individual table through DataTable.Select()?
>
> How can you go about getting the identity of a new record if you use an
> autoincrement primary key on the datatable?
>
> Thanks
Author
11 May 2007 10:22 PM
Miha Markic
www.queryadataset.com

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"deciacco" <a@a> wrote in message
news:jN2dnbx1v-ucVdnbnZ2dnUVZ_vOlnZ2d@giganews.com...
> Is there a way to query an in-memory dataset with sql or can you only work
> with the individual table through DataTable.Select()?
>
> How can you go about getting the identity of a new record if you use an
> autoincrement primary key on the datatable?
>
> Thanks
Author
12 May 2007 1:54 PM
Adrian Moore
www.queryadataset.com provides a complete set of SQL commands for
interacting with a Dataset in the same way you interact with a database.  A
standard .NET Provider interface is also close to being ready.

To get the next value of an identity column, use the following technique.
First, use DataTable.NewRow to get the next value.  Unfortately, this will
leave a gap the next time you insert, so you have to set the
autoincrementstep to its negative value, request a new row, then reset the
autoincrementstep.

row = dt.NewRow

dt.Columns(id).AutoIncrementStep = -1
dt.NewRow()
dt.Columns(id).AutoIncrementStep = 1
Hope this helps

Adrian Moore
http://www.queryadataset.com
Microsoft MVP - Windows Networking (P2P)



Show quote
"deciacco" <a@a> wrote in message
news:jN2dnbx1v-ucVdnbnZ2dnUVZ_vOlnZ2d@giganews.com...
> Is there a way to query an in-memory dataset with sql or can you only work
> with the individual table through DataTable.Select()?
>
> How can you go about getting the identity of a new record if you use an
> autoincrement primary key on the datatable?
>
> Thanks
Author
12 May 2007 2:00 PM
Adrian Moore
Its also interesting to note that SQL-Server does not allow multiple
identity columns in a table while a Dataset does.

Ad.

Show quote
"Adrian Moore" <adrian***@hotmail.com> wrote in message
news:umuyU0JlHHA.4628@TK2MSFTNGP06.phx.gbl...
> www.queryadataset.com provides a complete set of SQL commands for
> interacting with a Dataset in the same way you interact with a database.
> A standard .NET Provider interface is also close to being ready.
>
> To get the next value of an identity column, use the following technique.
> First, use DataTable.NewRow to get the next value.  Unfortately, this will
> leave a gap the next time you insert, so you have to set the
> autoincrementstep to its negative value, request a new row, then reset the
> autoincrementstep.
>
> row = dt.NewRow
>
> dt.Columns(id).AutoIncrementStep = -1
> dt.NewRow()
> dt.Columns(id).AutoIncrementStep = 1
> Hope this helps
>
> Adrian Moore
> http://www.queryadataset.com
> Microsoft MVP - Windows Networking (P2P)
>
>
>
> "deciacco" <a@a> wrote in message
> news:jN2dnbx1v-ucVdnbnZ2dnUVZ_vOlnZ2d@giganews.com...
>> Is there a way to query an in-memory dataset with sql or can you only
>> work with the individual table through DataTable.Select()?
>>
>> How can you go about getting the identity of a new record if you use an
>> autoincrement primary key on the datatable?
>>
>> Thanks
>
>

AddThis Social Bookmark Button