Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Add DataColumn to DataSet

Reply
Thread Tools

Add DataColumn to DataSet

 
 
Azkaban
Guest
Posts: n/a
 
      10-18-2004
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?bWpvZmFycmVsbA==?=
Guest
Posts: n/a
 
      10-18-2004
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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change in Display values in Boolean DataColumn in DataGridView Lucky ASP .Net 3 06-27-2006 12:18 PM
Check to see DataColumn DataType is Boolean? Jay Balapa ASP .Net 1 05-03-2006 11:04 PM
Converting DataColumn to Arrays Sanjay Tibrewal ASP .Net 0 03-18-2006 08:30 PM
How to format Date Inside DataColumn =?Utf-8?B?UmFlZCBTYXdhbGhh?= ASP .Net 1 11-04-2004 11:49 AM
UserControl in Template DataColumn =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?= ASP .Net 3 02-26-2004 09:42 AM



Advertisments