473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InMemory DataSet

I want to create an In Memory dataset. not connected to any database.. but
putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian
Aug 2 '08 #1
12 1424
On Aug 2, 6:43*pm, "Brian" <bsgalla...@com munity.nospamwr ote:
I want to create an In Memory dataset. *not connected to any database..but
putting my own info in from code or a file....
What are the steps to do this? *Where can I find some info on how to do
this?
* * * Brian
Dim dataSet As New DataSet()

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 2 '08 #2
All DataSets are in-memory and disconnected from any data source.

You should simply Google on .NET DataSet and read the many usefull articles
about them.

-Scott

"Brian" <bs********@com munity.nospamwr ote in message
news:OT******** ******@TK2MSFTN GP05.phx.gbl...
>I want to create an In Memory dataset. not connected to any database.. but
putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian

Aug 3 '08 #3
lol...
ok.. a little more info...
I want to create a table with a few columns... and a few rows....

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:ca******** *************** ***********@c65 g2000hsa.google groups.com...
On Aug 2, 6:43 pm, "Brian" <bsgalla...@com munity.nospamwr ote:
I want to create an In Memory dataset. not connected to any database.. but
putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian
Dim dataSet As New DataSet()

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 3 '08 #4
Brian wrote:
>
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:ca******** *************** ***********@c65 g2000hsa.google groups.com...
On Aug 2, 6:43 pm, "Brian" <bsgalla...@com munity.nospamwr ote:
>I want to create an In Memory dataset. not connected to any
database..

Dim dataSet As New DataSet()

lol...
ok.. a little more info...
I want to create a table with a few columns... and a few rows....
Same principle applies:
Dim DS As New DataSet("MyData Set")
Dim DT As New DataTable("MyTa ble")
DT.Columns.Add( "Test", GetType(String) )
Dim DR As DataRow = DT.NewRow
DR.Item("Test") = "Hello, World"
DT.Rows.Add(DR)
DS.Tables.Add(D T)
DS.AcceptChange s()
' all done



Aug 3 '08 #5
ok... how do i make bind that with a dataview?...
here are the crazy things I've been trying
Public Class Form1

Private MyDS As DataSet = New DataSet

Private MyTable As DataTable = MyDS.Tables.Add ("tblHoliday s") 'New
DataTable("tblH olidays")

Private Sub testme()

'Dim dt As New DataTable("tblH olidays")

Dim dcfirstcolumn As New DataColumn("fir st")

Dim dcsecondcolumn As New DataColumn("sec ond")

dcfirstcolumn.D ataType = System.Type.Get Type("System.Da teTime")

dcsecondcolumn. DataType = System.Type.Get Type("System.St ring")

MyTable.Columns .Add(dcfirstcol umn)

MyTable.Columns .Add(dcsecondco lumn)

Dim dr As DataRow = MyTable.NewRow( ) '= dt.Rows.Add ' 'dt.rows.newrow

MyTable.Rows.Ad d(dr)

dr.Item(dcfirst column) = #1/1/2008#

dr.Item(dcsecon dcolumn) = "New Years"

dr.AcceptChange s()

'MyTable.Rows(1 ).Item(0) = #1/1/2009#

' dr.

Me.DataGridView 1.DataSource = Me.MyDS.Tables

MyDS.AcceptChan ges()

'Me.DataGridVie w1.DataBindings

End Sub

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'With MyDS

' With MyTable

' .Columns.Add("d tmHoliday", Type.GetType("S ystem.DateTime" ))

' .Columns.Add("s trHoliday", Type.GetType("S ystem.String"))

' .Columns(1).Col umnName = "test"

' .Columns(0).Cap tion = "test caption"

' End With

' Console.WriteLi ne("Rows: {0}", .Tables(0).Rows .Count)

' MyTable.Rows.Ad d()

' Dim strSQL As String = "INSERT INTO tblHolidays (dtmHoliday, strHoliday)
values (#1/1/2009#, 'Testme')"

' Dim selectCMD As SqlClient.SqlCo mmand = New SqlClient.SqlCo mmand(strSQL)

' 'selectCMD.Exec uteScalar()

' Console.WriteLi ne("Rows: {0}", .Tables(0).Rows .Count)

' .AcceptChanges( )

Dim DS As New DataSet("MyData Set")

Dim DT As New DataTable("MyTa ble")

DT.Columns.Add( "Test", GetType(String) )

Dim DR As DataRow = DT.NewRow

DR.Item("Test") = "Hello, World"

DT.Rows.Add(DR)

DS.Tables.Add(D T)

DS.AcceptChange s()

Me.DataGridView 1.DataSource = DS.Tables

'End With

'testme()

End Sub

End Class



"Steve Gerrard" <my********@com cast.netwrote in message
news:NP******** *************** *******@comcast .com...
Brian wrote:
>>
"rowe_newsgrou ps" <ro********@yah oo.comwrote in message
news:ca******* *************** ************@c6 5g2000hsa.googl egroups.com...
On Aug 2, 6:43 pm, "Brian" <bsgalla...@com munity.nospamwr ote:
>>I want to create an In Memory dataset. not connected to any
database..

Dim dataSet As New DataSet()

lol...
ok.. a little more info...
I want to create a table with a few columns... and a few rows....

Same principle applies:
Dim DS As New DataSet("MyData Set")
Dim DT As New DataTable("MyTa ble")
DT.Columns.Add( "Test", GetType(String) )
Dim DR As DataRow = DT.NewRow
DR.Item("Test") = "Hello, World"
DT.Rows.Add(DR)
DS.Tables.Add(D T)
DS.AcceptChange s()
' all done



Aug 3 '08 #6
Brian wrote:
ok... how do i make bind that with a dataview?...
here are the crazy things I've been trying

Me.DataGridView 1.DataSource = DS.Tables
And the problem is what? :)

You may just need to try one of these two:
Me.DataGridView 1.DataSource = DS.Tables("MyTa ble")
or
Me.DataGridView 1.DataSource = DS
Me.DataGridView 1.DataMember = "MyTable"

Aug 3 '08 #7
Brian,

You use the code to set the datasource of a datagrid, that can be a dataset.

A dataGridView only accept one table. Probably the DataGrid was to complex
and therefore Microsoft has introduced an in fact more simple "Data" grid.

By the way, be aware that the "acceptchan ges" is not really needed in the
sample from Steve.
It can be done, does not harm, but that depends if you want to keep the
adding of the start row as new row ar as begin row.

I also would not use the literal dates. It is from the time that Microsoft
was probably thinking that they were a local player on the markt and
therefore only really suitable in the USA.

After a lot of discussions in past in this newsgroup, we came with this as
the best solution to initiate a date.

dim mydate as datetime = new datetime(2008, 1, 1)
giving as result in every place on earth the first day of january of the
year 2008.

Cor
"Brian" <bs********@com munity.nospamsc hreef in bericht
news:OR******** ******@TK2MSFTN GP02.phx.gbl...
ok... how do i make bind that with a dataview?...
here are the crazy things I've been trying
Public Class Form1

Private MyDS As DataSet = New DataSet

Private MyTable As DataTable = MyDS.Tables.Add ("tblHoliday s") 'New
DataTable("tblH olidays")

Private Sub testme()

'Dim dt As New DataTable("tblH olidays")

Dim dcfirstcolumn As New DataColumn("fir st")

Dim dcsecondcolumn As New DataColumn("sec ond")

dcfirstcolumn.D ataType = System.Type.Get Type("System.Da teTime")

dcsecondcolumn. DataType = System.Type.Get Type("System.St ring")

MyTable.Columns .Add(dcfirstcol umn)

MyTable.Columns .Add(dcsecondco lumn)

Dim dr As DataRow = MyTable.NewRow( ) '= dt.Rows.Add ' 'dt.rows.newrow

MyTable.Rows.Ad d(dr)

dr.Item(dcfirst column) = #1/1/2008#

dr.Item(dcsecon dcolumn) = "New Years"

dr.AcceptChange s()

'MyTable.Rows(1 ).Item(0) = #1/1/2009#

' dr.

Me.DataGridView 1.DataSource = Me.MyDS.Tables

MyDS.AcceptChan ges()

'Me.DataGridVie w1.DataBindings

End Sub

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'With MyDS

' With MyTable

' .Columns.Add("d tmHoliday", Type.GetType("S ystem.DateTime" ))

' .Columns.Add("s trHoliday", Type.GetType("S ystem.String"))

' .Columns(1).Col umnName = "test"

' .Columns(0).Cap tion = "test caption"

' End With

' Console.WriteLi ne("Rows: {0}", .Tables(0).Rows .Count)

' MyTable.Rows.Ad d()

' Dim strSQL As String = "INSERT INTO tblHolidays (dtmHoliday, strHoliday)
values (#1/1/2009#, 'Testme')"

' Dim selectCMD As SqlClient.SqlCo mmand = New SqlClient.SqlCo mmand(strSQL)

' 'selectCMD.Exec uteScalar()

' Console.WriteLi ne("Rows: {0}", .Tables(0).Rows .Count)

' .AcceptChanges( )

Dim DS As New DataSet("MyData Set")

Dim DT As New DataTable("MyTa ble")

DT.Columns.Add( "Test", GetType(String) )

Dim DR As DataRow = DT.NewRow

DR.Item("Test") = "Hello, World"

DT.Rows.Add(DR)

DS.Tables.Add(D T)

DS.AcceptChange s()

Me.DataGridView 1.DataSource = DS.Tables

'End With

'testme()

End Sub

End Class



"Steve Gerrard" <my********@com cast.netwrote in message
news:NP******** *************** *******@comcast .com...
>Brian wrote:
>>>
"rowe_newsgro ups" <ro********@yah oo.comwrote in message
news:ca****** *************** *************@c 65g2000hsa.goog legroups.com...
On Aug 2, 6:43 pm, "Brian" <bsgalla...@com munity.nospamwr ote:
I want to create an In Memory dataset. not connected to any
database..

Dim dataSet As New DataSet()

lol...
ok.. a little more info...
I want to create a table with a few columns... and a few rows....

Same principle applies:
Dim DS As New DataSet("MyData Set")
Dim DT As New DataTable("MyTa ble")
DT.Columns.Add( "Test", GetType(String) )
Dim DR As DataRow = DT.NewRow
DR.Item("Test") = "Hello, World"
DT.Rows.Add(DR)
DS.Tables.Add(D T)
DS.AcceptChange s()
' all done



Aug 3 '08 #8
There is another middle ground approach.

Create a strongl (-ly typed) dataset. And do it in memory.

Here is a crappy example I just wrote up for another person.

Sorry for the c# syntax, it'll convert easy.
Create a new strongly typed DataSet. Call it "StateStuff DS" (or whatever
you want to call it, try to avoid ambiguity)

Add 3 tables (with the columns)

State
StateID (int)
StateName (string)
StateAbbreviati on (string)

StateRule
StateRuleID (int)
StateRuleText (string)
StateToStateRul e
StateID (int)
StateRuleID (int)


Here is some psedu code.
StateStuffDS ds = new StateStuffDS();

ds.State.AddNew StateRow( 101, "Virginia", "VA");
ds.StateRule.Ad dNewStateRule ( 1001, "Is For Lovers" );
ds.StateToState Rule.AddStateTo StateRule( 101, 1001);

ds.WriteXml (@"C:\myds.xml" );
............... ..........

StateStuffDS anotherDS = new StateStuffDS();
anotherDS.Read( "C:\myds.xm l");
DataRow [] foundRows = ds.State.Select ("StateAbbrevia tion = 'VA'");
//include the System.Data namespace

if(foundRows.Le ngth 0) //or is it .Count?
{
StateStuffDS.St ate.StateRow currentRow = foundRows[0] as
StateStuffDS.St ate.StateRow; //just a test to pop off the first row
if(null!= currentRow)
{
Console.Writeli ne (currentRow.Sta teName);
}
}

You get some strong typing this way, even in the DataSet model.


Good luck!


"Brian" <bs********@com munity.nospamwr ote in message
news:OT******** ******@TK2MSFTN GP05.phx.gbl...
>I want to create an In Memory dataset. not connected to any database.. but
putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian

Aug 4 '08 #9
sloan,

A strongly typed dataset is normally inheriting the dataset class, I miss
that in your code.

Any idea what I miss?

Cor

"sloan" <sl***@ipass.ne tschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
There is another middle ground approach.

Create a strongl (-ly typed) dataset. And do it in memory.

Here is a crappy example I just wrote up for another person.

Sorry for the c# syntax, it'll convert easy.
Create a new strongly typed DataSet. Call it "StateStuff DS" (or whatever
you want to call it, try to avoid ambiguity)

Add 3 tables (with the columns)

State
StateID (int)
StateName (string)
StateAbbreviati on (string)

StateRule
StateRuleID (int)
StateRuleText (string)
StateToStateRul e
StateID (int)
StateRuleID (int)


Here is some psedu code.
StateStuffDS ds = new StateStuffDS();

ds.State.AddNew StateRow( 101, "Virginia", "VA");
ds.StateRule.Ad dNewStateRule ( 1001, "Is For Lovers" );
ds.StateToState Rule.AddStateTo StateRule( 101, 1001);

ds.WriteXml (@"C:\myds.xml" );
............... .........

StateStuffDS anotherDS = new StateStuffDS();
anotherDS.Read( "C:\myds.xm l");
DataRow [] foundRows = ds.State.Select ("StateAbbrevia tion = 'VA'");
//include the System.Data namespace

if(foundRows.Le ngth 0) //or is it .Count?
{
StateStuffDS.St ate.StateRow currentRow = foundRows[0] as
StateStuffDS.St ate.StateRow; //just a test to pop off the first row
if(null!= currentRow)
{
Console.Writeli ne (currentRow.Sta teName);
}
}

You get some strong typing this way, even in the DataSet model.


Good luck!


"Brian" <bs********@com munity.nospamwr ote in message
news:OT******** ******@TK2MSFTN GP05.phx.gbl...
>>I want to create an In Memory dataset. not connected to any database..
but putting my own info in from code or a file....
What are the steps to do this? Where can I find some info on how to do
this?
Brian

Aug 4 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4594
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. I'm getting some strange results depending the input XML file I use. I was wondering if somebody could help me understand what is going on or point me to a good reference. The code for my program looks like this:
1
4308
by: Andy | last post by:
Hello, I have a WebService that sends a client a DataSet as XML (I use a DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter in the WebService. The client coverts the XML Back to a DataSet (using StringReader sr = new StringReader(xml); DataSet ds = new DataSet(); ds.ReadXml(sr)). The client then makes changes to this DataSet, and sends the dirty dataset back to the WebService using another GetXml on 'ds'. The...
5
5398
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an actual DataSet? e.g. public class MyDataSet : DataSet { // can't do, no valid DataSet constructor
2
3379
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and then appends the data to a dataset that is built in the Page_Load code in the if(!isPostBack) block. When I try to add a row in the button click event code I get an error saying that "Object reference not set to an instance of an object". I'm...
22
25575
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
2
1642
by: Jan | last post by:
Regarding my post "CSharpCodeProvider: referencing other generated "InMemory" assembly" 4/27/2006 and the blog from Greg Young http://geekswithblogs.net/gyoung/archive/2006/04/27/76533.aspx I have now implemented a fine system with code semilar to Greg's example code. I have a warning/comment/question: When the generated main assembly is called for the first time (in my application a static initialize function) another instance of...
2
2526
by: Wolfgang Hauer | last post by:
Hallo! Ich habe eine inmemory-bitmap. die ich leider in eine png-datei umwandeln muss. ich mache das jetzzt so: b = New Bitmap(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(sFullName)) If b Is Nothing Then
1
2525
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then can re-run the report and get fresh data. now, they would like to be able to compare the fresh data to the stored data, getting a break-down of added/deleted/changed rows. on the surface, this sounded plausible -- by deserializing the stored
3
2483
by: Martin Z | last post by:
Hi, I have an application that involves sending a lot of XML data to various places. The problem is that once in a while, I just want the XML document as a string (for example, sending to a typed dataset tableadaptor). In that case, I have a problem: what encoding do I use to conver the byte (or memorystream) into a string? The encoding is in the file, of course, like any XML file, but how do I find out which? I tried using an...
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.