473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

shared Dataset

I have seen some posts on this subject but I still cannot make my app work right.

I have a MDI application with a parent form and two child forms.
The parent form is called Mainform
The child forms are called invoiceForm and customerForm

I have a dataset containing customer info which I would like to make available to all forms.
The dataset is called dsCustomers

So in my parent form code in the general declarations area I have this
Expand|Select|Wrap|Line Numbers
  1. Public Shared WithEvents DSCust As New InvoiceWhiz.dsCustomers
  2. Public custForm As New customerForm
  3. Public invForm as new invoiceForm
  4.  
I open each form from MainForm like this
[code]
invForm.MdiParent = Me
custForm.MdiParent = Me
invForm.Show()
custForm.show()
[\code]

I reference the dataset from the children like this

[code]

datagrid.datasource = Mainform.DSCust.customer

[\code]

All of this builds with no errors and runs fine at first then VS gives an error like this

C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\InvoiceWhiz\customerForm.vb(70): The variable 'DSCust' is either undeclared or was never assigned.

And then erases my reference in the child code.

Cany anyone help me out on this?
Thanks,
Kratz


From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 21 '05 #1
7 1931

well instead of making it public availlable you could probably better pass
it to the other form as a parameter if the data is required for he life of
the object you could pass it in the constructor

regards

Michel Posseth


"kratz" <kr***@koyote.com> wrote in message
news:06**********************************@msnews.m icrosoft.com...
I have seen some posts on this subject but I still cannot make my app work
right.

I have a MDI application with a parent form and two child forms.
The parent form is called Mainform
The child forms are called invoiceForm and customerForm

I have a dataset containing customer info which I would like to make
available to all forms.
The dataset is called dsCustomers

So in my parent form code in the general declarations area I have this
Expand|Select|Wrap|Line Numbers
  1.     Public Shared WithEvents DSCust As New InvoiceWhiz.dsCustomers
  2.     Public custForm As New customerForm
  3.     Public invForm as new invoiceForm
  4.  

I open each form from MainForm like this
[code]
invForm.MdiParent = Me
custForm.MdiParent = Me
invForm.Show()
custForm.show()
[\code]

I reference the dataset from the children like this

[code]

datagrid.datasource = Mainform.DSCust.customer

[\code]

All of this builds with no errors and runs fine at first then VS gives an
error like this

C:\Documents and Settings\Administrator\My Documents\Visual Studio
Projects\InvoiceWhiz\customerForm.vb(70): The variable 'DSCust' is either
undeclared or was never assigned.

And then erases my reference in the child code.

Cany anyone help me out on this?
Thanks,
Kratz


From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Nov 21 '05 #2
Hi Kratz,

I am going to give the best help that 'I' can! It may not answer your
question(s) but I guess it should work. Maybe others with more db knowledge
will post something more descriptive.

I am not sure how you actually get your data into the dataset, whether you
code the connection perhaps and use the Fill method of the dataadapter, or
whether you are dragging connection components onto your form from within
the IDE.

Not sure why you use WithEvents. Datasets only have one event which is
MergeFailed (other than dispose!). Perhaps you are using this!!

I would probably do something like

(MainForm)

Public dsMain as New Dataset
(MainForm Load Event)

'Declare and instantiate data components
da.Fill(dsMain, "Results")

(mdiForms)

dgMdi.DataSource = MainForm.dsMain
dgMdi.DataMember = "Results"

HTH, Phil
"kratz" <kr***@koyote.com> wrote in message
news:06**********************************@msnews.m icrosoft.com...
I have seen some posts on this subject but I still cannot make my app work
right.

I have a MDI application with a parent form and two child forms.
The parent form is called Mainform
The child forms are called invoiceForm and customerForm

I have a dataset containing customer info which I would like to make
available to all forms.
The dataset is called dsCustomers

So in my parent form code in the general declarations area I have this
Expand|Select|Wrap|Line Numbers
  1.     Public Shared WithEvents DSCust As New InvoiceWhiz.dsCustomers
  2.     Public custForm As New customerForm
  3.     Public invForm as new invoiceForm
  4.  

I open each form from MainForm like this
[code]
invForm.MdiParent = Me
custForm.MdiParent = Me
invForm.Show()
custForm.show()
[\code]

I reference the dataset from the children like this

[code]

datagrid.datasource = Mainform.DSCust.customer

[\code]

All of this builds with no errors and runs fine at first then VS gives an
error like this

C:\Documents and Settings\Administrator\My Documents\Visual Studio
Projects\InvoiceWhiz\customerForm.vb(70): The variable 'DSCust' is either
undeclared or was never assigned.

And then erases my reference in the child code.

Cany anyone help me out on this?
Thanks,
Kratz


From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Nov 21 '05 #3
Just a suggestion but I would create a class for my database procedures and
set up properties and methods for setting and returning data from/to my
database and/or dataset. I think you will find this a lot easier to keep up
your database/dataset iaccess procedures if they are in one class. You can
instantiate this class in your mainform and access it
"MainForm.myDBClass.myProperty or make it global.

--
Dennis in Houston
"kratz" wrote:
I have seen some posts on this subject but I still cannot make my app work right.

I have a MDI application with a parent form and two child forms.
The parent form is called Mainform
The child forms are called invoiceForm and customerForm

I have a dataset containing customer info which I would like to make available to all forms.
The dataset is called dsCustomers

So in my parent form code in the general declarations area I have this
Expand|Select|Wrap|Line Numbers
  1.      Public Shared WithEvents DSCust As New InvoiceWhiz.dsCustomers
  2.      Public custForm As New customerForm
  3.      Public invForm as new invoiceForm
  4.  

I open each form from MainForm like this
[code]
invForm.MdiParent = Me
custForm.MdiParent = Me
invForm.Show()
custForm.show()
[\code]

I reference the dataset from the children like this

[code]

datagrid.datasource = Mainform.DSCust.customer

[\code]

All of this builds with no errors and runs fine at first then VS gives an error like this

C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\InvoiceWhiz\customerForm.vb(70): The variable 'DSCust' is either undeclared or was never assigned.

And then erases my reference in the child code.

Cany anyone help me out on this?
Thanks,
Kratz


From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Nov 21 '05 #4
Thanks to all for the suggestions. I decided to try Michel's suggestions
first. So in my ParentForm code I have

Private DSCust As New xxxxx.dsCustomers
Public custForm As New customerForm(DSCust)
Public invForm As New invoiceform(DSCust)

in the general declarations area.

Then in each childForm code I have

Public Sub New(ByRef DsCust As xxxxx.dsCustomers)

but when I try to reference the dataset in child code like this

datagrid.datasource = DsCust.customer

I get errors saying "Name 'DsCust' is not declared"

What am I doing wrong?
Thanks again,
Kratz

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 21 '05 #5
well i would go for an aproach like this

Public Class clsMain
Private dsMain As New DataSet
Friend Sub justamethod()
Dim cchild As New ClsChild(dsMain)
cchild.PerformActionsOnDS()
dsMain = cchild.dsRet
End Sub
End Class

Friend Class ClsChild
Private _ds As DataSet
Friend ReadOnly Property dsRet() As DataSet
Get
Return _ds
End Get
End Property
Friend Sub New(ByVal ds As DataSet)
_ds = ds
End Sub
Friend Sub PerformActionsOnDS()
'poerform you actions on the dataset
End Sub
End Class
clschild can "live" on its own when the required dataset is passed
"kratz" wrote:
Thanks to all for the suggestions. I decided to try Michel's suggestions
first. So in my ParentForm code I have

Private DSCust As New xxxxx.dsCustomers
Public custForm As New customerForm(DSCust)
Public invForm As New invoiceform(DSCust)

in the general declarations area.

Then in each childForm code I have

Public Sub New(ByRef DsCust As xxxxx.dsCustomers)

but when I try to reference the dataset in child code like this

datagrid.datasource = DsCust.customer

I get errors saying "Name 'DsCust' is not declared"

What am I doing wrong?
Thanks again,
Kratz

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Nov 21 '05 #6
Michel thanks so much for the help. I got it working. I still have one
question though. When you have a property like this
Public class2
Public Property ds as TypedDataset
Get
Set
End Property

If you set the property from another class like

class2.ds = me.datasetWithData

does it just do a copy of the structure of the dataset and leave out the
data?

thanks again,
Kratz

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 21 '05 #7
it will copy the hole dataset inclusive the data

regards

Michel posseth
"kratz" wrote:
Michel thanks so much for the help. I got it working. I still have one
question though. When you have a property like this
Public class2
Public Property ds as TypedDataset
Get
Set
End Property

If you set the property from another class like

class2.ds = me.datasetWithData

does it just do a copy of the structure of the dataset and leave out the
data?

thanks again,
Kratz

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Nov 21 '05 #8

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

Similar topics

3
by: tom | last post by:
Hello, I'm using the ms data access application blocks. My question is about the fact that everywhere shared methods are used. Does this mean that when more than 1 user at the same time...
2
by: Trevor Oakley | last post by:
I am writing thousands of html pages from an MS SQL source using a DataSet and then an XslTransform. I have an interest in making the code run faster as it takes several minutes (sometimes ten...
2
by: nakhi | last post by:
Hi, I declared a dataset outside any subs, then I fill the dataset with a tables in a Private Sub1, then I want to take the data out from the dataset in Sub2. like . sub2()...
10
by: Daniel Fernandes | last post by:
Hi there Let's say due to several reasons I have an ASP.Net application that has a database access class that stores a database connection in a shared member : public class dataaccess ...
9
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same...
2
by: John Granade | last post by:
I'm looking for the best way to make a dataset available from multiple Windows forms. The dataset is created from an XML file. I have a main form (frmMain) that loads the dataset and reads the...
5
by: Confused ! | last post by:
I am writing an ASP.NET application and I want to use shared members on the data layer to retreive information from the SQL Server. If I declare a Function to be Shared, how will this affect...
11
by: Mr Newbie | last post by:
I'm still thinking around this subject, and I find myself unsure about a couple of things. When a new users launches an ASP.NET application, this must be on a new thread. When it encounters a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.