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

Add DataColumn to DataSet

Hi I succeded to add a DataColumn to DataSet but now I've one big problem.
The value of this column would be a personal function result, I try a lot of
time but the result is always empty.
Why?
There's a method to do this thing?

This is the code
cols = ImageDataSet.Tables("Immagini").Columns
myCol = cols.Add()
With myCol
.DataType = System.Type.GetType("System.String")
.ColumnName = "IPTC"
.Expression = ReadIPTCProperty("Path")
.ReadOnly = True
.Unique = False
End With

And this is the function:

Private Function ReadIPTCProperty(ByVal Path As String) As String
Dim gr As New Graphic
gr.ReadIPTC = True
gr.SetFile(Path)
Dim ip As Graphic.IPTCItem
For Each ip In gr.IPTC
If UCase(ip.Name) = "CAPTION" Then
ReadIPTCProperty = "'" & ip.Text & "'"
End If
Next
End Function

Thank you.
--
Filippo Macchi
www.filippomacchi.it
Nov 18 '05 #1
1 1581
You cannot set a 'column' to a value. You can set a column within a row to a
value:

e.g. ImageDataSet.Tables("Immagini").Rows(0).Item(myCol .ColumnName) = ...

or you can set the default value of a column:

e.g. myCol.DefaultValue = ...

The structure of a dataset can be a little confusing:

Dataset - contains Tables
Tables - contains Columns and Rows
Columns - can have expressions (to filter / calculate, create aggregate cols)
Rows - Contains Items (refering to the columns!)

So it is the Item property you should be trying to access.
Also try using the 'return' statement in your personal function - just to
make sure you are actually returning data from it:

.....
Dim strRet as String
For Each ip In gr.IPTC
If UCase(ip.Name) = "CAPTION" Then
strRet = "'" & ip.Text & "'"
End If
Next
Return strRet
......

Mark

"Azkaban" wrote:
Hi I succeded to add a DataColumn to DataSet but now I've one big problem.
The value of this column would be a personal function result, I try a lot of
time but the result is always empty.
Why?
There's a method to do this thing?

This is the code
cols = ImageDataSet.Tables("Immagini").Columns
myCol = cols.Add()
With myCol
.DataType = System.Type.GetType("System.String")
.ColumnName = "IPTC"
.Expression = ReadIPTCProperty("Path")
.ReadOnly = True
.Unique = False
End With

And this is the function:

Private Function ReadIPTCProperty(ByVal Path As String) As String
Dim gr As New Graphic
gr.ReadIPTC = True
gr.SetFile(Path)
Dim ip As Graphic.IPTCItem
For Each ip In gr.IPTC
If UCase(ip.Name) = "CAPTION" Then
ReadIPTCProperty = "'" & ip.Text & "'"
End If
Next
End Function

Thank you.
--
Filippo Macchi
www.filippomacchi.it

Nov 18 '05 #2

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

Similar topics

8
by: Christian Dokman | last post by:
Hello, I'd like to fill a dataset column with a product-description. Sometimes the size of the description-text is longer than 255 characters. At that length, the dataset automatically cuts off...
0
by: SoYouKnowBrig | last post by:
Hi All, I am using Microsoft.ApplicationBlocks.Cache.CacheManager to persist a System.Data.Dataset object. This Dataset object has a DataTable that is created from an existing DataTable using...
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
4
by: ALI-R | last post by:
Is it a possibel to assign an array to a DataColumn then bind it to a Combo box?? Is the follwoing code right? public static DataSet InsertParamsToDS(ReportParameter arrParams) { DataSet...
5
by: Larry Bird | last post by:
I've created a AlertDataClass below within the class I have tables and column that I've create. In the AlertDataAccess class I'm trying to insert data into my tables. AlertDataAccess is a Module...
4
by: bordsby | last post by:
Situation: I am using an OleDbDataAdapter to fill a DataSet's DataTable with data from an Access database. The DataSet's DataTable is bound to a DataGrid. After the OleDbDataAdapter.Fill method...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
0
by: SWIL | last post by:
Hi, I made my own datacolumn Class which inherits from Data.DataColumn. To this class I have added 2 properties. To add datacolumn created through my new class I have to call.. ...
1
by: Sagaert Johan | last post by:
Hi When i add a datacolumn to a dataset and then call Update on the dataset then my MS Access datbase does not reflect the changes.(no coumn was added to the table) DataColumn newcolumn =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.