asp.net vb existing datatable add row


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: asp.net vb existing datatable add row

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Posts
    8

    asp.net vb existing datatable add row

    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?

    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

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I would add the records to my underlaying database table then reconstruct the dataset.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Dec 2004
    Posts
    8
    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.

Similar Threads

  1. Replies: 0
    Last Post: 08-31-2005, 02:44 AM
  2. Replies: 1
    Last Post: 08-27-2002, 08:27 AM
  3. Add column to existing Access2000 table
    By James in forum VB Classic
    Replies: 5
    Last Post: 11-28-2001, 02:05 AM
  4. URGENT :: JTable - to add row
    By barnaboss in forum Java
    Replies: 1
    Last Post: 03-15-2001, 11:54 AM
  5. INHERITS and NAMESPACES - VB, ASP.NET
    By Paul Murphy in forum ASP.NET
    Replies: 1
    Last Post: 11-29-2000, 03:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center