473,725 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Tables to DataSet in Component

Hi all,

I'm trying to create a dataset as a component to make it accessable from all
forms. I have used that following code so far in the component designer:

Inherits System.Componen tModel.Componen t
Dim _TryDs As dataSet = NewTry

Public Property dataSet() As dataSet
Get
Return Me._TryDs
End Get
Set(ByVal Value As dataSet)
Me._TryDs = Value
End Set
End Property

Now I have no idea how to add the 2 tables. I have created 2 subs
"createTabl eA" and "createTabl eB" and added the commands
createTableA()
createTableB()
after the initialize component line.

When I try to reference the component the DS is recognized but the tables
are not. I know I'm missing something here. Can anybody help?
Thanks,
Claus
Nov 21 '05
12 1827
Cor,

if I dim ds as New GlobalDS.MyData set the program runs but the DataGrid on
the second form is empty, so I thought I had to leave the NEW out on the
second form.

I guess that was wrong.

Claus

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...
Claus,

What I cannot see is if Global.Dataset is an object or the class itself.
When it is the class or a member of that than it has to be probably
dim ds as "new" GlobalDS.MyData set

I hope this helps?

Cor

"cjobes" <cj****@nova-tech.org>

Sorry to be so stupid but I must still be doing something wrong. I created the component and defined the tables. I then created an instance in form1 and manipulated the data. As a test I brought a DataGrid up in form1 and
it
displays the data correctly.
I created a second form (SearchResult) with a DataGrid(Result Grid) and
added
the following code:

Dim ds As GlobalDS.MyData set
Dim dt As DataTable = ds.tbSelect

Private Sub SearchResult_Lo ad(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.ResultGrid.D ataMember = "dt"
Me.ResultGrid.D ataSource = ds
End Sub

On form1 I added the code:
Dim frmResults As New SearchResult()
frmResults.Show Dialog()

When I run Debug the program stops at:
Dim dt as DataTable=ds.tb Select
with an error "Object reference not set to an instance of an object"

What am I doing wrong?

Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
Claus,

I see I deleted with pasting in the sample a part I had answered as well
>
> If I fill the tables with data in one
> form and then create an instance of the tables in another form will the > data
> still be there?
>
That class is nothing, the object you create from it holds the data, and than it is the same as whatever you create.

Assuming this is for a winform (it is not the same for a webform), than
means when you do

Friend ds as new mydataset

somewhere in your project, than it will everywhere in your project be

usable
with the information in it. (As long as you do not set it too something else of course)

I hope this helps?

Cor



Nov 21 '05 #11
Cor,

I played around with this a bit further. When I add this code to Form1

Dim frmResults As New SearchResult()
frmResults.Data Set = ds
frmResults.Show Dialog()

and this code to Form2

Public WriteOnly Property DataSet() As DataSet
Set(ByVal Value As DataSet)
ResultGrid.Data Source = Value
End Set
End Property

the DataGrid displays the correct data. But I also need to be able to
further manipulate the data in both tables on Form2 and I don't seem to be
able to do that.

Claus

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...
Claus,

What I cannot see is if Global.Dataset is an object or the class itself.
When it is the class or a member of that than it has to be probably
dim ds as "new" GlobalDS.MyData set

I hope this helps?

Cor

"cjobes" <cj****@nova-tech.org>

Sorry to be so stupid but I must still be doing something wrong. I created the component and defined the tables. I then created an instance in form1 and manipulated the data. As a test I brought a DataGrid up in form1 and
it
displays the data correctly.
I created a second form (SearchResult) with a DataGrid(Result Grid) and
added
the following code:

Dim ds As GlobalDS.MyData set
Dim dt As DataTable = ds.tbSelect

Private Sub SearchResult_Lo ad(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.ResultGrid.D ataMember = "dt"
Me.ResultGrid.D ataSource = ds
End Sub

On form1 I added the code:
Dim frmResults As New SearchResult()
frmResults.Show Dialog()

When I run Debug the program stops at:
Dim dt as DataTable=ds.tb Select
with an error "Object reference not set to an instance of an object"

What am I doing wrong?

Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
Claus,

I see I deleted with pasting in the sample a part I had answered as well
>
> If I fill the tables with data in one
> form and then create an instance of the tables in another form will the > data
> still be there?
>
That class is nothing, the object you create from it holds the data, and than it is the same as whatever you create.

Assuming this is for a winform (it is not the same for a webform), than
means when you do

Friend ds as new mydataset

somewhere in your project, than it will everywhere in your project be

usable
with the information in it. (As long as you do not set it too something else of course)

I hope this helps?

Cor



Nov 21 '05 #12
Found a way to do it and thanks to Charlie I got the final hiccup out as
well.

Thanks for your help Cor, knowing my skills it will not be the last time I'm
asking for help in here.

Claus
"cjobes" <cj****@nova-tech.org> wrote in message
news:e4******** ******@TK2MSFTN GP09.phx.gbl...
Cor,

I played around with this a bit further. When I add this code to Form1

Dim frmResults As New SearchResult()
frmResults.Data Set = ds
frmResults.Show Dialog()

and this code to Form2

Public WriteOnly Property DataSet() As DataSet
Set(ByVal Value As DataSet)
ResultGrid.Data Source = Value
End Set
End Property

the DataGrid displays the correct data. But I also need to be able to
further manipulate the data in both tables on Form2 and I don't seem to be
able to do that.

Claus

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...
Claus,

What I cannot see is if Global.Dataset is an object or the class itself.
When it is the class or a member of that than it has to be probably
dim ds as "new" GlobalDS.MyData set

I hope this helps?

Cor

"cjobes" <cj****@nova-tech.org>

Sorry to be so stupid but I must still be doing something wrong. I

created the component and defined the tables. I then created an instance in form1 and manipulated the data. As a test I brought a DataGrid up in form1 and it
displays the data correctly.
I created a second form (SearchResult) with a DataGrid(Result Grid) and
added
the following code:

Dim ds As GlobalDS.MyData set
Dim dt As DataTable = ds.tbSelect

Private Sub SearchResult_Lo ad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Me.ResultGrid.D ataMember = "dt"
Me.ResultGrid.D ataSource = ds
End Sub

On form1 I added the code:
Dim frmResults As New SearchResult()
frmResults.Show Dialog()

When I run Debug the program stops at:
Dim dt as DataTable=ds.tb Select
with an error "Object reference not set to an instance of an object"

What am I doing wrong?

Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
> Claus,
>
> I see I deleted with pasting in the sample a part I had answered as well>
> >
> > If I fill the tables with data in one
> > form and then create an instance of the tables in another form will the> > data
> > still be there?
> >
> That class is nothing, the object you create from it holds the data, and> than it is the same as whatever you create.
>
> Assuming this is for a winform (it is not the same for a webform), than> means when you do
>
> Friend ds as new mydataset
>
> somewhere in your project, than it will everywhere in your project be
usable
> with the information in it. (As long as you do not set it too something> else of course)
>
> I hope this helps?
>
> Cor
>
>



Nov 21 '05 #13

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

Similar topics

10
4011
by: Eric Petruzzelli | last post by:
If I fill my dataset and there is no data. The dataset is still created with zero rows (all columns are there). When I add my first row using the script below, it takes over 2 seconds to add??? If I add the second row, instant. How can I eliminate this delay?
4
5482
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
3
2407
by: satria | last post by:
hi all, i have a accesslevel table's that has 2 field, id and accesslevelname. i successfully binded the table to datagrid, but i'd like to display a new column, called number. so it 'll display : number | accesslevelname 1 user 2 supervisor ....
10
2343
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to the DataAdd part (Section heading is Adding Rows to a DataSet) I dont really know what to do after i have added all the
16
2483
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill it with incremental values e.g. if the tables looks like this: 23 56
1
2822
by: DotNetJunkies User | last post by:
I'm trying create a single page app that allows the user to enter text (Serial) via a form and submit and populate that value into a datagrid via a datatable. It works for ONE value but each time a new row is added, it replaces the 1st. Somehow I'm reinitalizing the table, but not sure what I'm doing wrong because I'm very new at this stuff..... Thanks Devon :>
6
4427
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire row doesn't get filled. I have a connection and all that stuff. Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceBet.Click ' Dim Myds As Footbet.DStable '...
6
2240
by: Mark | last post by:
I'm trying to add a table to a dataset but get the error: "A DataTable named 'BordDates0040' already belongs to this DataSet." Code: Dim dtBordDates As DataTable dtBordDates = LoadTable(strDBPath & strDBName, strTableName, strSQL) Dim ds2 As DataSet = New DataSet()
12
6219
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my code: //Function For Importing Data From CSV File public DataSet ConnectCSV(string filetable)
0
8888
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
8752
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,...
0
9401
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9111
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...
0
8096
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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
4517
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...
1
3221
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
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.