Add DataColumn to DataSet

Discussion in 'ASP .Net' started by Azkaban, Oct 18, 2004.

  1. Azkaban

    Azkaban Guest

    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
    Azkaban, Oct 18, 2004
    #1
    1. Advertising

  2. 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
    >
    >
    >
    =?Utf-8?B?bWpvZmFycmVsbA==?=, Oct 18, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=

    UserControl in Template DataColumn

    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    470
    Martin Dechev
    Feb 26, 2004
  2. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    How to format Date Inside DataColumn

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,304
    =?Utf-8?B?UHN5Y2hv?=
    Nov 4, 2004
  3. Sanjay Tibrewal

    Converting DataColumn to Arrays

    Sanjay Tibrewal, Mar 18, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    463
    Sanjay Tibrewal
    Mar 18, 2006
  4. Jay Balapa
    Replies:
    1
    Views:
    7,981
    Bjorn Abelli
    May 4, 2006
  5. Lucky
    Replies:
    3
    Views:
    3,955
    Vadivel Kumar
    Jun 27, 2006
Loading...

Share This Page