473,795 Members | 3,024 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 1453
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 #21
Klaus, maybe, the following link will give you some ideas:

http://www.smithvoice.com/vbfun.htm

On the left side bar select: VB.NET and then DB Copier.net
There is a program there that generates code from a database. He will send you the source code ot his program if you email him
directly. Maybe this is what you are looking for.
james


"Klaus Jensen" <CurseThemNasty Spammers!> wrote in message news:uv******** ******@tk2msftn gp13.phx.gbl...
"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 #22
Klaus, maybe, the following link will give you some ideas:

http://www.smithvoice.com/vbfun.htm

On the left side bar select: VB.NET and then DB Copier.net
There is a program there that generates code from a database. He will send you the source code ot his program if you email him
directly. Maybe this is what you are looking for.
james


"Klaus Jensen" <CurseThemNasty Spammers!> wrote in message news:uv******** ******@tk2msftn gp13.phx.gbl...
"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 #23
On 2004-11-12, Klaus Jensen <> wrote:
"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:


Reflection isn't what you want. Reflection will only work on a compiled
assembly, and that isn't what you have.

The easiest solution here is to simply find the relevant XML file.
Don't worry about the class or the class code for the typed dataset,
find the appropriate xml file in the project and it's trivial to use an
xpath to parse out the columns in any specific table.




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 #24
On 2004-11-12, Klaus Jensen <> wrote:
"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:


Reflection isn't what you want. Reflection will only work on a compiled
assembly, and that isn't what you have.

The easiest solution here is to simply find the relevant XML file.
Don't worry about the class or the class code for the typed dataset,
find the appropriate xml file in the project and it's trivial to use an
xpath to parse out the columns in any specific table.




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 #25

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
7407
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
9519
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
10215
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
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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
9043
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 projectplanning, coding, testing, and deploymentwithout 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...
0
6783
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();...
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.