Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 26th, 2004, 12:34 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default How to get the value from the DataTable column

Hi everybody,
I have a .NET question:
I've created a disconnected OleDb.DataSet. After that I filled in the DataTable for this DataSet using OleDb.DataAdapter. Than, I would like to read some data from some fields in this DataTable. How to get the field value without using DataReader? I am trying to use collections (first table (index 0) in the Tables collection and column (index 11) in the Columns collection:
myVariable = myDataSet.Tables(0).Columns(11).ToString, it returns the column name. How to get the actual value from the column? I could not find any example on the WEB and Microsoft Help.
Any ideas?

Thanks
-Dmitriy.;)
Reply With Quote
  #2 (permalink)  
Old September 27th, 2006, 11:55 AM
Registered User
 
Join Date: Sep 2006
Location: Phnom Penh, , Cambodia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

just try this

in VB.NET
variable as String=DataSet.Table(0).Rows(index)(column-index).ToString();

in C#.NET

string variable=DataSet.Table[0].Rows[index][column-index].ToString();

Example:

string name=DataSet.Table[0].Rows[3][2].ToString();


hope this help you.

best regards.

Reply With Quote
  #3 (permalink)  
Old March 27th, 2008, 05:39 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get the following error when I try your advice:
Error 1 Cannot apply indexing with [] to an expression of type 'System.Data.DataTable'

Reply With Quote
  #4 (permalink)  
Old March 31st, 2008, 01:09 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Why would you post your .NET question in the VB6 forum?
Reply With Quote
  #5 (permalink)  
Old March 30th, 2010, 08:58 AM
Authorized User
 
Join Date: Jan 2010
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elizas Send a message via Skype™ to elizas
Default Getting the Calculated value for a new column of a DataTable in .NET

DataTable class in .Net supports the calculation of a column by getting the values from other columns.

That means lets say I have a DataTable as dtItems which is having three columns ItemName, Price, Quantity ,if I need to add another column as Total and the calculated value for this column will be Price* Quantity , this can be done easily without looping through all the rows, it will be automatically calculated during runtime " dtItems.Columns.Add("Total", typeof(int), "Price*Quantity"); ".
__________________
Cheers,
Eliza

Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rearrange the column order in a datatable/dataset kiran_q8 ASP.NET 2.0 Basics 6 July 3rd, 2007 12:12 PM
Rearrange the column order in a datatable/dataset kiran_q8 ASP.NET 2.0 Professional 2 May 3rd, 2007 08:46 AM
Adding up Column Values within a Datatable rit01 ASP.NET 2.0 Basics 1 May 31st, 2006 11:27 AM
Adding rows, AND column(s) to existing datatable cliffd64 VB.NET 2002/2003 Basics 1 August 18th, 2005 06:50 AM
Compare two Items of data(in column A and column B ever Excel VBA 6 February 13th, 2004 01:19 PM



All times are GMT -4. The time now is 06:06 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.