473,397 Members | 2,068 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,397 software developers and data experts.

Accessing a dataset from an object on a different form

Using VB.Net and ADO:

I've created a public variable on my main form and set it to = a dataset
which was crrated with the designer. I have another form with a datagrid on
it. In the designer, I can't set the datasource property to the dataset on
the main form, although i can do it in code.

Can someone tell me how to declare a dataset, either in a form or module,
that I can use globally throughout my application, including in the
designer? I have a hierarchical dataset and need to use a hierarchical grid
control, setting all of it's various properties and structure at run time is
problematic.

Thanks!
Nov 20 '05 #1
3 3343
Cor
Hi Mike,

When you create a dataset in the designer, you will find the dataset.vb
class file in your solution explorer, when you do "show all files" in the
tree beneath the XSD.

You can give the reference from an object to another class, if you create
the right methods for that in those other classes (Do not try to change that
XSD vb class, when you do that you can never more use the designer for that
dataset).

I hope this helps?

Cor

I've created a public variable on my main form and set it to = a dataset
which was crrated with the designer. I have another form with a datagrid on it. In the designer, I can't set the datasource property to the dataset on the main form, although i can do it in code.

Can someone tell me how to declare a dataset, either in a form or module,
that I can use globally throughout my application, including in the
designer? I have a hierarchical dataset and need to use a hierarchical grid control, setting all of it's various properties and structure at run time is problematic.

Thanks!

Nov 20 '05 #2
Hmm, color me dense:

I can create a dataset class using the solution explorer, and I can create a
global instance of it on my main form. I can then use that instance as a
datasouce in a table in code.

What I can't do is to use that global dataset in the designer as the
datasouce. I guess the datasouce property doesn't show datasouces unless
they are bound to forms somehow at design time. That's what I'm trying to
accomplish.

It sounds like you are saying this can be done in the forms class definition
somehow, but I don't know exactly how to do this.

Thanks for replying.

Mike

"Cor" <no*@non.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Hi Mike,

When you create a dataset in the designer, you will find the dataset.vb
class file in your solution explorer, when you do "show all files" in the
tree beneath the XSD.

You can give the reference from an object to another class, if you create
the right methods for that in those other classes (Do not try to change that XSD vb class, when you do that you can never more use the designer for that dataset).

I hope this helps?

Cor

I've created a public variable on my main form and set it to = a dataset
which was crrated with the designer. I have another form with a datagrid
on
it. In the designer, I can't set the datasource property to the dataset on
the main form, although i can do it in code.

Can someone tell me how to declare a dataset, either in a form or

module, that I can use globally throughout my application, including in the
designer? I have a hierarchical dataset and need to use a hierarchical

grid
control, setting all of it's various properties and structure at run

time is
problematic.

Thanks!


Nov 20 '05 #3
Cor
Hi Mike,

First of all I never do it this way, I made a sample to try it myself
first.
It did what I though it would do.

But I did test nothing further.
So I don't know if there are side effects.

The sample is bellow

I made a project with 2 forms
I made on form1 a connection draging the SQLadapter on form1 and connected
it the Nortwind table employees
On every form I did drag a datagrid and on the first one a button.
I did using the designer to change the datasource of the datagrid on form1
to dataset11.employees
Than I added the code bellow

The form did show up with the information on form1 in the datagrid
When I did push on button1 the datagrid with the information was showed on
form2 in the datagrid.

I hope this helps?

Cor

\\\
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2
frm.DataSet11 = DataSet11
frm.ShowDialog()
End Sub
Private Sub Form1_Load(ByVal sender As _
Object, ByVal e As System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
End Sub
End Class
///
\\\
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Friend WithEvents DataSet11 As WindowsApplication8.DataSet1
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.DataGrid1.DataSource = DataSet11.Employees
End Sub
End Class
///
I can create a dataset class using the solution explorer, and I can create a global instance of it on my main form. I can then use that instance as a
datasouce in a table in code.

What I can't do is to use that global dataset in the designer as the
datasouce. I guess the datasouce property doesn't show datasouces unless
they are bound to forms somehow at design time. That's what I'm trying to
accomplish.

It sounds like you are saying this can be done in the forms class definition somehow, but I don't know exactly how to do this.

Nov 20 '05 #4

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

Similar topics

6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
2
by: Greg Merideth | last post by:
Using Visual C# I created two forms such as namespace test { public class SystemTray : System.Windows.Forms.Form { public createwindow() { stuff here; } public fadewindow() { stuff to fade...
3
by: Bill | last post by:
I have a seating chart web form that has over 50 entry field controls (tables/booths) where I use a DropDownList box to select a single company name from a single large list of organizations (200...
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
0
by: N. Demos | last post by:
Hello, I'm having problems accessing a complex XML child node (latitude & longitude), and passing it to a function when the XML file has been read into a DataSet. Specifically, the returned object...
2
by: Debbie Carter | last post by:
I have a few questions about databases. I would like to load only certain records into a datagrid. For an example, with a list of customers I want to only load the customers from California so in...
5
by: Darious Snell | last post by:
I am using windows forms and vb.net. My problem is a little complex so please bear with me. I have written an application that references a .com based API linked to an external client...
4
by: Andy B | last post by:
I have a wizard on a page that will dynamically create a dataset as it goes along based on user input. When the wizard is done, it will dump all of the data it collected/created in the wizard to an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
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...
0
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...

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.