Add DataColumn to DataSet

A

Azkaban

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top