Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2008, 04:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default DataSet

I have a Dataset that I want to add a column to if a value in the Dataset is a certain value.

Dim da As New OleDbDataAdapter(strSQL, strConn)
Dim myDataSet As New DataSet
da.Fill(myDataSet, "dtAnswers")

Dim r As DataRow
Dim myDataTable As DataTable = myDataSet.Tables("dtAnswers")
myDataTable.Columns.Add(New DataColumn("thenotes", GetType(String)))

Dim i As Integer
For Each r In myDataSet.Tables("dtAnswers").Rows
   Response.Write(r("statusid") & " ")
   For i = 0 To myDataTable.Rows.Count - 1
       myDataTable.Rows(i)("thenotes") = r("statusid")
    Next
 Next

The response.write is displaying the correct statusid(s) but I can't figure out how to add that to the column rows. It currently prints the very last ID on every row.

 
Old January 28th, 2008, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Solved:
Dim i As Integer
For i = 0 To myDataTable.Rows.Count - 1
   Dim r As DataRow = myDataSet.Tables(0).Rows(i)
   myDataTable.Rows(i)("thenotes") = myFunction(r("statusid"))
Next i






Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill a DataSet from another DataSet kamranzafar C# 1 February 7th, 2007 11:14 AM
Fill(dataset) or dataset.load() salemkoten SQL Server 2005 1 November 2nd, 2006 11:04 PM
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Copy dataset to another dataset kapila VB.NET 2 November 13th, 2005 06:25 AM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.