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 12 1823
Cjobes,
Does this most simple sample that I once made for somebody give you an idea?
\\\
Public Class MyDataset
Inherits DataSet
Sub New()
MyBase.new()
Dim dt As New DataTable("Tabl eKlaus")
Me.Tables.Add(d t)
dt.Columns.Add( "Klaus")
dt.Columns.Add( "Cor")
End Sub
Public ReadOnly Property TableKlaus() As DataTable
Get
Return Me.Tables("Tabl eKlaus")
End Get
End Property
End Class
///
dim ds as new MyDataset
dim dt as datatable = ds.TableKlaus
I hope this gives some ideas?
Cor
"cjobes" <cj****@nova-tech.org> schreef in bericht
news:O1******** *****@TK2MSFTNG P09.phx.gbl... 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
Cor,
Thanks a lot. I'm starting to understand this. I assume that your sample
code goes into the component code. I have two more questions:
I need to create 2 tables. Would I do this in the same public class? Also,
could you give me a short sample of what I need to do in a form to create
and instance of the 2 tables?
Actually there is one more question. 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?
Thanks,
Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oc******** ******@TK2MSFTN GP15.phx.gbl... Cjobes,
Does this most simple sample that I once made for somebody give you an
idea? \\\ Public Class MyDataset Inherits DataSet Sub New() MyBase.new() Dim dt As New DataTable("Tabl eKlaus") Me.Tables.Add(d t) dt.Columns.Add( "Klaus") dt.Columns.Add( "Cor") End Sub Public ReadOnly Property TableKlaus() As DataTable Get Return Me.Tables("Tabl eKlaus") End Get End Property End Class ///
dim ds as new MyDataset dim dt as datatable = ds.TableKlaus
I hope this gives some ideas?
Cor
"cjobes" <cj****@nova-tech.org> schreef in bericht news:O1******** *****@TK2MSFTNG P09.phx.gbl... 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
Claus, Thanks a lot. I'm starting to understand this. I assume that your sample code goes into the component code.
You cannot inherit twice however the dataset that is inherited does that
already see in top of this page http://msdn.microsoft.com/library/de...classtopic.asp
I have two more questions: I need to create 2 tables. Would I do this in the same public class? Also, could you give me a short sample of what I need to do in a form to create and instance of the 2 tables?
Everything you do is up to you, however why not. I showed the things above
in a new sample bellow however how far you go is again up to you. I made a
very simple sample where I made an extra datatable and load a datatable as
method in this extra and showed that table on a datagrid
\\\needs new project with a datagrid on the form
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim ds As New MyDataset
For i As Integer = 0 To 10
ds.KlausTableAd dNew(New Object() {i.ToString, ChrW(i + 65)})
Next
DataGrid1.DataS ource = ds.TableKlaus
End Sub
End Class
Public Class MyDataset
Inherits DataSet
Sub New()
MyBase.new()
Dim dt As New DataTable("Tabl eKlaus")
Me.Tables.Add(d t)
dt.Columns.Add( "Klaus")
dt.Columns.Add( "Cor")
dt = New DataTable("Tabl eCor")
Me.Tables.Add(d t)
dt.Columns.Add( "John")
dt.Columns.Add( "Herfried")
End Sub
Public ReadOnly Property TableKlaus() As DataTable
Get
Return Me.Tables("Tabl eKlaus")
End Get
End Property
Public ReadOnly Property TableCor() As DataTable
Get
Return Me.Tables("Tabl eCor")
End Get
End Property
Public Sub KlausTableAddNe w(ByVal obj As Object())
Dim dr As DataRow = Me.TableKlaus.N ewRow
dr.ItemArray = obj
Me.TableKlaus.R ows.Add(dr)
End Sub
End Class
///
I hope this helps a little bit?
Cor
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
Thanks Cor,
The handling of the additional table is what I thought but you have me
totally confused with "needs new project". I think I need some tutoring to
cut the learning curve in half. I'm happy to pay you for your time. Can you
contact me at cj****@nova-tech.org?
Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ol******** ********@TK2MSF TNGP11.phx.gbl. .. Claus,
Thanks a lot. I'm starting to understand this. I assume that your sample code goes into the component code. You cannot inherit twice however the dataset that is inherited does that already see in top of this page http://msdn.microsoft.com/library/de...classtopic.asp >I have two more questions: I need to create 2 tables. Would I do this in the same public class?
Also, could you give me a short sample of what I need to do in a form to
create and instance of the 2 tables?
Everything you do is up to you, however why not. I showed the things above in a new sample bellow however how far you go is again up to you. I made a very simple sample where I made an extra datatable and load a datatable as method in this extra and showed that table on a datagrid
\\\needs new project with a datagrid on the form Private Sub Form1_Load(ByVa l sender As Object, _ ByVal e As System.EventArg s) Handles MyBase.Load Dim ds As New MyDataset For i As Integer = 0 To 10 ds.KlausTableAd dNew(New Object() {i.ToString, ChrW(i + 65)}) Next DataGrid1.DataS ource = ds.TableKlaus End Sub End Class Public Class MyDataset Inherits DataSet Sub New() MyBase.new() Dim dt As New DataTable("Tabl eKlaus") Me.Tables.Add(d t) dt.Columns.Add( "Klaus") dt.Columns.Add( "Cor") dt = New DataTable("Tabl eCor") Me.Tables.Add(d t) dt.Columns.Add( "John") dt.Columns.Add( "Herfried") End Sub Public ReadOnly Property TableKlaus() As DataTable Get Return Me.Tables("Tabl eKlaus") End Get End Property Public ReadOnly Property TableCor() As DataTable Get Return Me.Tables("Tabl eCor") End Get End Property Public Sub KlausTableAddNe w(ByVal obj As Object()) Dim dr As DataRow = Me.TableKlaus.N ewRow dr.ItemArray = obj Me.TableKlaus.R ows.Add(dr) End Sub End Class ///
I hope this helps a little bit?
Cor
Claus,
That "needs new project" is only for trying the sample, nothing extra.
:-))
Cor
"cjobes" <cj****@nova-tech.org>
.... Thanks Cor,
The handling of the additional table is what I thought but you have me totally confused with "needs new project". I think I need some tutoring to cut the learning curve in half. I'm happy to pay you for your time. Can you contact me at cj****@nova-tech.org?
Claus
"Cor Ligthert" <no************ @planet.nl> wrote in message news:Ol******** ********@TK2MSF TNGP11.phx.gbl. .. Claus,
> Thanks a lot. I'm starting to understand this. I assume that your > sample > code goes into the component code.
You cannot inherit twice however the dataset that is inherited does that already see in top of this page http://msdn.microsoft.com/library/de...classtopic.asp >I have two more questions: > I need to create 2 tables. Would I do this in the same public class? Also, > could you give me a short sample of what I need to do in a form to create > and instance of the 2 tables?
Everything you do is up to you, however why not. I showed the things above in a new sample bellow however how far you go is again up to you. I made a very simple sample where I made an extra datatable and load a datatable as method in this extra and showed that table on a datagrid
\\\needs new project with a datagrid on the form Private Sub Form1_Load(ByVa l sender As Object, _ ByVal e As System.EventArg s) Handles MyBase.Load Dim ds As New MyDataset For i As Integer = 0 To 10 ds.KlausTableAd dNew(New Object() {i.ToString, ChrW(i + 65)}) Next DataGrid1.DataS ource = ds.TableKlaus End Sub End Class Public Class MyDataset Inherits DataSet Sub New() MyBase.new() Dim dt As New DataTable("Tabl eKlaus") Me.Tables.Add(d t) dt.Columns.Add( "Klaus") dt.Columns.Add( "Cor") dt = New DataTable("Tabl eCor") Me.Tables.Add(d t) dt.Columns.Add( "John") dt.Columns.Add( "Herfried") End Sub Public ReadOnly Property TableKlaus() As DataTable Get Return Me.Tables("Tabl eKlaus") End Get End Property Public ReadOnly Property TableCor() As DataTable Get Return Me.Tables("Tabl eCor") End Get End Property Public Sub KlausTableAddNe w(ByVal obj As Object()) Dim dr As DataRow = Me.TableKlaus.N ewRow dr.ItemArray = obj Me.TableKlaus.R ows.Add(dr) End Sub End Class ///
I hope this helps a little bit?
Cor
Thanks again Cor,
From your response I assume that you are not interested in making some
"tutor money". If you change your mind, you have my email.
I will try your suggestions tonight. Hopefully I understood everything
right. I'm a network guy with some experience in VB, so it will be very
interesting to say the least.
Thanks again, I really appreciate your patient help.
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
Cor,
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
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...
|
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
....
|
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
|
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
| |
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
:>
|
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
'...
|
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()
|
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)
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |