473,795 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deterimine columns of dataset from code - reflection?

Hi!

How do I explore in code, which properties (columns) are in a datatable? I
need to run some code for each column.

I guess the answer is reflection somehow, but I dont know where to start.

If someone could point me to a relevant example, I would be most grateful.
:)

Thanks in advance

- Klaus
Nov 21 '05
24 1452
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:eG******** ******@TK2MSFTN GP14.phx.gbl...
In fact is Nigel showing to you when you have that base dataset, how you
can do it. I saw his sample after that I had sand mine.


Maybe I am missing a point, but I still dont know how to come from the
string "Mydata.MyStron gtypedDataset" to an object of that type. When I have
the dataset as a correctly typed dataset, Nigels og your code is great for
displaying all columns... But the first part - I still dont know. :-S

- Klaus
Nov 21 '05 #11
Klaus,

You give me more and more the idea that you have a only a string
"Mydata.Mystron glytypeddataset " and absolute nothing more and want to make
from that a strongly typed dataset. I assume that I am wrong?.

Cor

Cor
"Klaus Jensen" <sp******@must. die>
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:eG******** ******@TK2MSFTN GP14.phx.gbl...
In fact is Nigel showing to you when you have that base dataset, how you
can do it. I saw his sample after that I had sand mine.


Maybe I am missing a point, but I still dont know how to come from the
string "Mydata.MyStron gtypedDataset" to an object of that type. When I
have the dataset as a correctly typed dataset, Nigels og your code is
great for displaying all columns... But the first part - I still dont
know. :-S

- Klaus

Nov 21 '05 #12
Klaus,

You give me more and more the idea that you have a only a string
"Mydata.Mystron glytypeddataset " and absolute nothing more and want to make
from that a strongly typed dataset. I assume that I am wrong?.

Cor

Cor
"Klaus Jensen" <sp******@must. die>
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:eG******** ******@TK2MSFTN GP14.phx.gbl...
In fact is Nigel showing to you when you have that base dataset, how you
can do it. I saw his sample after that I had sand mine.


Maybe I am missing a point, but I still dont know how to come from the
string "Mydata.MyStron gtypedDataset" to an object of that type. When I
have the dataset as a correctly typed dataset, Nigels og your code is
great for displaying all columns... But the first part - I still dont
know. :-S

- Klaus

Nov 21 '05 #13
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OD******** ******@TK2MSFTN GP14.phx.gbl...
You give me more and more the idea that you have a only a string
"Mydata.Mystron glytypeddataset " and absolute nothing more and want to make
from that a strongly typed dataset. I assume that I am wrong?.


Yes, you misunderstand me. I'll try explaining it again. :)

I already have a strong typed dataset. It is located in the MyData-namespace
and is called Mystronglytyped dataset.
Lets say the dataset has a table SomeTable with two columns:
- ID (integer)
- Name (string)

In an empty class I write this...:

Class MyBusinessClass

Private _mydataset as MyData.Mystrong lytypeddataset
Private _mydatarow as MyData.Mystrong lytypeddataset. SomeTable

End Class

Next step is, I mark the line "Private _mydatarow as
MyData.Mystrong lytypeddataset. SomeTable" and run a macro, which examines the
strong typed dataset and generates code, so the class now looks like this:

Public Class MyBusinessClass

Private _mydataset as MyData.Mystrong lytypeddataset
Private _mydatarow as MyData.Mystrong lytypeddataset. SomeTable 'mark this
row and run the macro

Public Property ID() As Integer
Get
Return _mydatarow.ID
End Get
Set(ByVal Value As Integer)
_mydatarow.ID = Value
End Set
End Property

Public Property Name() As String
Get
Return _mydatarow.Name
End Get
Set(ByVal Value As String)
_mydatarow.Name = Value
End Set
End Property

End Class

I hope this shows, what I have in mind. :)
Nov 21 '05 #14
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OD******** ******@TK2MSFTN GP14.phx.gbl...
You give me more and more the idea that you have a only a string
"Mydata.Mystron glytypeddataset " and absolute nothing more and want to make
from that a strongly typed dataset. I assume that I am wrong?.


Yes, you misunderstand me. I'll try explaining it again. :)

I already have a strong typed dataset. It is located in the MyData-namespace
and is called Mystronglytyped dataset.
Lets say the dataset has a table SomeTable with two columns:
- ID (integer)
- Name (string)

In an empty class I write this...:

Class MyBusinessClass

Private _mydataset as MyData.Mystrong lytypeddataset
Private _mydatarow as MyData.Mystrong lytypeddataset. SomeTable

End Class

Next step is, I mark the line "Private _mydatarow as
MyData.Mystrong lytypeddataset. SomeTable" and run a macro, which examines the
strong typed dataset and generates code, so the class now looks like this:

Public Class MyBusinessClass

Private _mydataset as MyData.Mystrong lytypeddataset
Private _mydatarow as MyData.Mystrong lytypeddataset. SomeTable 'mark this
row and run the macro

Public Property ID() As Integer
Get
Return _mydatarow.ID
End Get
Set(ByVal Value As Integer)
_mydatarow.ID = Value
End Set
End Property

Public Property Name() As String
Get
Return _mydatarow.Name
End Get
Set(ByVal Value As String)
_mydatarow.Name = Value
End Set
End Property

End Class

I hope this shows, what I have in mind. :)
Nov 21 '05 #15
Klaus,

For me the answer you describe stays the same as the first
See this

\\\
Public Module main
Public Sub main()
Dim mydat As New MyDataset
For Each dc As DataColumn In _
mydat.TableKlau s.Columns
MessageBox.Show (dc.ColumnName)
Next
End Sub
End Module
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
///

I hope this helps anyway?

Cor
Nov 21 '05 #16
Klaus,

For me the answer you describe stays the same as the first
See this

\\\
Public Module main
Public Sub main()
Dim mydat As New MyDataset
For Each dc As DataColumn In _
mydat.TableKlau s.Columns
MessageBox.Show (dc.ColumnName)
Next
End Sub
End Module
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
///

I hope this helps anyway?

Cor
Nov 21 '05 #17
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:et******** ******@TK2MSFTN GP09.phx.gbl...
For me the answer you describe stays the same as the first
See this
I hope this helps anyway?


I am afraid you do not understand, what I want to accomplish... I am not
sure how I can explain it differently...

The code you show me generates a dataset. I want code that dynamicly
examines any strong typed dataset, and generates some code/text from the
columns, that are in the strong typed dataset.

I really don't know how I can explain it differently... But I appreciate
your effort to help me. :)

- Klaus
Nov 21 '05 #18
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:et******** ******@TK2MSFTN GP09.phx.gbl...
For me the answer you describe stays the same as the first
See this
I hope this helps anyway?


I am afraid you do not understand, what I want to accomplish... I am not
sure how I can explain it differently...

The code you show me generates a dataset. I want code that dynamicly
examines any strong typed dataset, and generates some code/text from the
columns, that are in the strong typed dataset.

I really don't know how I can explain it differently... But I appreciate
your effort to help me. :)

- Klaus
Nov 21 '05 #19
Klaus,

I made a strongly typed dataset and retrieved the columns names from it,
what do you mean with a strongly typed dataset?

Only the first part is the sample how to do it, I needed a strongly typed
dataset to show, therefore I made the most simple one I could make.

Cor

"Klaus Jensen"
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:et******** ******@TK2MSFTN GP09.phx.gbl...
For me the answer you describe stays the same as the first
See this
I hope this helps anyway?


I am afraid you do not understand, what I want to accomplish... I am not
sure how I can explain it differently...

The code you show me generates a dataset. I want code that dynamicly
examines any strong typed dataset, and generates some code/text from the
columns, that are in the strong typed dataset.

I really don't know how I can explain it differently... But I appreciate
your effort to help me. :)

- Klaus

Nov 21 '05 #20

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

Similar topics

3
2550
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called "Resource" with the following structure : Resource{,en,fr,es} Yes.. these are the only languages supported actually. A couple of rows in that table would look like this :
0
1726
by: Jason Coyne Gaijin42 | last post by:
I have seen several people looking for a way to access the Columns collection when using the AutoGenerate = true option. Some people have gotten so far as to find the private autoGenColumnsArray that has the information, but we as developers have no way to access this information. I have come up with a solution for the problem, (as I am sure many others have) using reflection. Here is some sample code that will print out the auto...
2
864
by: Jason Coyne Gaijin42 | last post by:
I have seen several people looking for a way to access the Columns collection when using the AutoGenerate = true option. Some people have gotten so far as to find the private autoGenColumnsArray that has the information, but we as developers have no way to access this information. I have come up with a solution for the problem, (as I am sure many others have) using reflection. Here is some sample code that will print out the auto...
0
781
by: Klaus Jensen | last post by:
Hi! How do I explore in code, which properties (columns) are in a datatable? I need to run some code for each column. I guess the answer is reflection somehow, but I dont know where to start. If someone could point me to a relevant example, I would be most grateful. :)
2
2231
by: Kjetil Klaussen | last post by:
Hi, I’m having some troubles trying to bind my dataset to a GridView control through an ObjectDataSource control. The binding works fine for regular columns in my dataset, but I can’t seem to get my expression columns to show up in my GridView. Anybody knows any neat tricks to make this work? Here’s a “step-by-step” to reproduce my worries: 1. Create a new “ASP.NET web site” project
3
7406
by: ASPnewb1 | last post by:
I am currently filling a dataTable then adding this table to a dataset, setting the dataset to the Gridview's datasource. If I set the Gridview to generate columns automatically it will fill the grid just fine, but I can't get the automated column (column index 1) to be set to readonly. (Column 0 is actually an automated column of edit buttons) here's my code: DataSet ds = new DataSet(); DataTable dt = new DataTable();...
0
9672
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10438
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
10214
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 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...
1
7540
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
6780
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();...
0
5437
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
4113
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
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
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...

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.