|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Query in memory dataset c# 2Is 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 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(). -- Show quote____________________________________ 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) ----------------------------------------------------------------------------------------------------------------------- "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
www.queryadataset.com
--
Show quote
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/ "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
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 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 > > |
|||||||||||||||||||||||