asp.net vb existing datatable add row

Discussion in '.NET' started by janetb, Feb 5, 2010.

  1. janetb

    janetb

    Joined:
    Nov 8, 2006
    Messages:
    5
    I need to add rows to an existing (maybe) datatable in a dataset that combines the IIS6 index search with my own sql table. I keep getting object reference errors. Anybody help me out? Much thanks.

    Code:
            If ds.Tables("list").Rows.Count > 0 Then
                For Each k As Data.DataRow In ds.Tables("list").Rows
                    Dim myDate As String
                    If Convert.ToInt32(k.Item("structure")) = 4 Then
                        myDate = "Online - " & k.Item("eTitle").ToString
                    Else
                        myDate = k.Item("mDate").ToString & "  - " & k.Item("eTitle").ToString
                    End If
                    Dim objRow As System.Data.DataRow = ds.Tables("listSearch").NewRow
                    objRow("filename") = "Some Class"
                    objRow("characterization") = myDate
                    objRow("rank") = "1100"
                    objRow("path") = "SomePath.apsx?eid=22"
                    ds.Tables("listSearch").Rows.Add(objRow)
                Next
            End If
    janetb, Feb 5, 2010
    #1
    1. Advertising

  2. janetb

    janetb

    Joined:
    Nov 8, 2006
    Messages:
    5
    Figured out what I was doing wrong. I was binding the first dataset and then adding the second set so it didn't get added to the display. Switched things around and it's working beautifully now. Sorry to be so dense. Hope this helps someone else.
    janetb, Feb 8, 2010
    #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. Ersin Gençtürk
    Replies:
    1
    Views:
    3,477
    Ersin Gençtürk
    Oct 6, 2004
  2. MattB

    add row from dataview to DataTable

    MattB, Nov 9, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    9,465
    MattB
    Nov 10, 2005
  3. =?Utf-8?B?UGF0cmljayBG?=

    Add a row to datatable

    =?Utf-8?B?UGF0cmljayBG?=, Aug 8, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    447
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 8, 2006
  4. Paul
    Replies:
    1
    Views:
    2,266
    Hermit Dave
    Jul 11, 2008
  5. GoodMorningSky

    How to add New Column to existing DataTable in specific position.

    GoodMorningSky, Oct 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    1,252
    Alex Homer
    Oct 6, 2004
Loading...

Share This Page