asp.net add datarow to existing dataset table

asp.net , dataset , data row United States
  • 7 years ago

    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?

    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
    
  • 7 years ago

    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.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond