Creating A DataSet Programmatically

From: V. Jenks (anonymous_at_discussions.microsoft.com)
Date: 12/11/04


Date: Sat, 11 Dec 2004 15:53:38 -0800

You can access this in a number of ways or even write it to
disk, that's actually quite a loaded question. If you had
done a little research you'd have quickly found answers to
this.

You can write a DataSet to disk and read it back into a
DataSet in memory whenever you like, you may also generate
schemas for the XML you generate, see here:

http://samples.gotdotnet.com/quickstart/howto/doc/Xml/SaveDataSetXML.aspx

As for reading into a database, there are a number of ways
to do this. A DataSet is a database represented in memory
and is composed of XML (to make a long story short).

It is comprised of DataTables, DataViews, DataRelations,
etc. You can use DataReaders to read data out of the
DataSet or you can use Commands to write data into your
database. You can even create relationships between
DataTables in memory and enforce integrity.

There's obviously much more, try these links for starters:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconxmldataset.asp

http://www.c-sharpcorner.com/database/ado.net.tut.sh.asp

http://www.411asp.net/home/tutorial/specific/database/classes/dataset

>-----Original Message-----
>The following ASPX code snippet creates a DataSet
programmatically right from the scratch:
>
>'create an empty DataSet
>Dim objDS As New DataSet("MyDataSet")
>
>'create a new table & add columns
>Dim dTable As New DataTable("Users")
>dTable.Columns.Add("ID",System.Type.GetType("System.Int32"))
>dTable.Columns.Add("FirstName",System.Type.GetType("System.String"))
>dTable.Columns.Add("LastName",System.Type.GetType("System.String"))
>dTable.Columns("ID").AutoIncrement=True
>
>'add the new table
>objDS.Tables.Add(dTable)
>
>'define the Primary Key
>Dim keys As DataColumn={objDS.Tables("Users").Columns("ID")}
>objDS.Tables("Users").PrimaryKey=keys
>
>'add a row to this table
>Dim dRow As DataRow=dTable.NewRow()
>dRow(1)="Michael"
>dRow(2)="Johnson"
>dTable.Rows.Add(dRow)
>
>As such, the above code doesn't generate any errors but
how do I access this DataSet i.e. how do I convert it into
an actual file or insert it in a database so that I can
access the data that it stores (presently it stores only
one row - Michael as the FirstName & Johnson as the LastName)?
>
>Thanks,
>
>Arpan



Relevant Pages

  • Re: Out of memory?
    ... Extensive disk testing needs to read / write to the disk and aren't ... Having so many database problems ... is read into memory but it can exceed the available memory. ... I suspect your AD got corrupt in a bad way (I recall your previous ...
    (microsoft.public.windows.server.sbs)
  • Re: Modeling events that occur in a game world
    ... A good DB only goes to disk when RAM is not available. ... Which DBs can you imbed completely in memory like this? ... In biz apps a database is usually available and assumed available. ...
    (comp.object)
  • Re: CLOS and databases
    ... J> all my data in a database. ... J> using a database (not directly allocating memory), ... The hard part would probably be defgeneric and defmethod. ... J> disk, until it exaust the entire system. ...
    (comp.lang.lisp)
  • Re: Out of memory?
    ... Diags are usually pretty good about memory and cpu test and the disk ... Having so many database problems ... I suspect your AD got corrupt in a bad way (I recall your previous ...
    (microsoft.public.windows.server.sbs)
  • Re: Abysmal eseutil /d performance
    ... Be advised that the progress bar ... new stores and moved the mailboxes to them, ... The database is massive. ... The disk array has about 100GB of unallocated disk ...
    (microsoft.public.exchange.admin)

Loading