By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,899 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,899 IT Pros & Developers. It's quick & easy.

Add DataColumn to DataSet

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.