I have a class that performs a few methods on a dataset. That dataset then
fills a grid on a form. What I would like to do is to assign a particular
dataset to the class at runtime.
For instance, if I have 5 datasets named dataset1 through dataset5, how can
I call the class from my form, pass the dataset I want to manipulate and then
bind that dataset to a datagrid on the form?
Each dataset will bind to its own datagrid. Any ideas?
Thanks 4 1867
Have you checked out the Microsoft Data Access Applicaiton Block - http://msdn.microsoft.com/library/de.../html/daab.asp
It essentially handles this for you. But essentially you can just pass in
the datasets just like any other object. You can create a collection if
you'd like to hold those datasets so that you can iterate through them.
Can you tell me a little more about the problem and I'll probably be able to
help out a little more.
"Andrew Carlson" <andrew(nospam)@aimrecords.com> wrote in message
news:B9**********************************@microsof t.com... I have a class that performs a few methods on a dataset. That dataset then fills a grid on a form. What I would like to do is to assign a particular dataset to the class at runtime.
For instance, if I have 5 datasets named dataset1 through dataset5, how can I call the class from my form, pass the dataset I want to manipulate and then bind that dataset to a datagrid on the form?
Each dataset will bind to its own datagrid. Any ideas?
Thanks
Thanks for responding.
In this instance I am not using a database as such. I am parsing out
delimited files and feeding them into a datatable. I am very comfortable in
ADO.net and so I dump the files into that. However, I need to calculate
against data in these fields. Simple enough to do but I am trying for code
reuse. Essentially, I have a class that consumes the data from the text file
and places the values in the proper place in the datatable.
Here is an example of the call
Dim parsedif as new App.DIF2Dataset
Dim openfile As New OpenFileDialog
openfile.Filter = "DIF files (*.dif)|*.dif"
openfile.ShowDialog()
If openfile.FileName <> Nothing Then
parsedif.Input = openfile.FileName
End If
parsedif.Output = App.dtRCGDIF 'This is the target datatable
parsedif.Parse() 'This is the method to
consume and structure the data.
MsgBox(dtRCGDIF.Rows(1).Item(2)) 'here it fails. The output property
is just a way to point at a public datatable. This class is simply for
gathering the data and making it something I can easily navigate through. The
error is "System.NullReferenceException".
How is it losing its reference when the datatable is public? (it is in a
module btw)
How do I access a dataset or datatable from any class in an application,
change it, and access it somewhere else?
thanks again
"Andrew Carlson" <andrew(nospam)@aimrecords.com> wrote in message
news:89**********************************@microsof t.com... Thanks for responding. In this instance I am not using a database as such. I am parsing out delimited files and feeding them into a datatable. I am very comfortable in ADO.net and so I dump the files into that. However, I need to calculate against data in these fields. Simple enough to do but I am trying for code reuse. Essentially, I have a class that consumes the data from the text file and places the values in the proper place in the datatable.
Here is an example of the call Dim parsedif as new App.DIF2Dataset Dim openfile As New OpenFileDialog openfile.Filter = "DIF files (*.dif)|*.dif" openfile.ShowDialog() If openfile.FileName <> Nothing Then parsedif.Input = openfile.FileName End If parsedif.Output = App.dtRCGDIF 'This is the target datatable
This appears to be incorrect. I would expect something more like
App.dtRCGDIF = parsedif.Parse();
or
parsedif.Parse()
App.dtRCGDIF = parseDif.Output
parsedif.Parse() 'This is the method to consume and structure the data. MsgBox(dtRCGDIF.Rows(1).Item(2)) 'here it fails. The output property is just a way to point at a public datatable. This class is simply for gathering the data and making it something I can easily navigate through. The error is "System.NullReferenceException".
How is it losing its reference when the datatable is public? (it is in a module btw)
How do I access a dataset or datatable from any class in an application, change it, and access it somewhere else?
I apoligize for the confusion. Although this says .Output, I am setting a
property in the class. I am telling the class what datatable to use. When the
..Parse method is done, the datatable should be available to bind to a
datagrid. However, it is not. That is where I am stuck.
"Andrew Carlson" wrote: I have a class that performs a few methods on a dataset. That dataset then fills a grid on a form. What I would like to do is to assign a particular dataset to the class at runtime.
For instance, if I have 5 datasets named dataset1 through dataset5, how can I call the class from my form, pass the dataset I want to manipulate and then bind that dataset to a datagrid on the form?
Each dataset will bind to its own datagrid. Any ideas?
Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ville Vainio |
last post by:
Pythonic Nirvana - towards a true Object Oriented Environment
=============================================================
IPython (by Francois Pinard) recently (next release - changes are...
|
by: D Witherspoon |
last post by:
I am developing a Windows Forms application in VB.NET that will use .NET
remoting to access the data tier classes.
A very simple way I have come up with is by creating typed (.xsd) datasets.
For...
|
by: Andrew Carlson |
last post by:
I have a class that performs a few methods on a dataset. That dataset then
fills a grid on a form. What I would like to do is to assign a particular
dataset to the class at runtime.
For...
|
by: Patrick |
last post by:
Hi all,
New to .NET, I'm working on an Winforms client application using VS
2005 beta2. My needs considering data storage are the followings:
(1) Small files (0 < length < 10 mb), containing...
|
by: Randall Parker |
last post by:
Suppose you want to do either of these:
A) Set display properties (e.g. color or boldness of text) of a cell based on a value
of another cell in the same row.
B) Set the display properties of...
|
by: andrea |
last post by:
Sorry for the stupid question, I know, but sometimes is necessary starts
from the basic.
I don't know how to pass the result of a method generated from a DAL class
to a BL class
returning the...
|
by: Water Cooler v2 |
last post by:
I am new to PHP, just one day new. But I am otherwise a seasoned
programmer on many other languages like C, VB 6, C#, VB.NET, Win32
platform and have some tiny bit experience in MFC, C++, Python.
...
|
by: Techno_Dex |
last post by:
I'm wanting to create a Wrapper (or Extender depending on how you look at
it) for a Serializable object that I then want to send over a webservice.
Basically I want to create a Serializable Object,...
|
by: Steve |
last post by:
I am building an object library for tables in a database. What is the
best practice for creating objects like this?
For example, say I have the following tables in my database:
User:
- Id
-...
|
by: notnorwegian |
last post by:
i have some confusion over this.
sure a class is basically a classification, like for example an animal
or flower. and an object/instance of that class is then for example a
cat.
an object is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |