Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Data.DataRow

Status
Not open for further replies.

TheConeHead

Programmer
Joined
Aug 14, 2002
Messages
2,106
Location
US
I am getting data via:

Code:
System.Data.DataRow tComment = commentsDS.Tables["table"].Rows[l];

but I only get "System.Data.DataRow" outputted - when I try to convert it to a string to output I get an error saying you cannot convert System.Data.DataRow to a string... any ideas?

[conehead]
 
Yes, it is correct that you can't convert a DataRow to a String - they are completely different objects. To get a value out of one of the Items in the DataRow, use:
Code:
commentsDS.Tables("table").Rows(0).Item(0).ToString


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ok - thanks for the reply - I tried:

Code:
System.Data.DataRow tComment = commentsDS.Tables["table"].Rows[l].ToString();

but I still get the error:

Cannot implicitly convert type 'string' to 'System.Data.DataRow'

any ideas?

[conehead]
 
Re-read my post and example again...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ok - I see - now I tried:

Code:
commentsDS.Tables("table").Rows(l).Item("column").ToString;

and I get:

'System.Data.DataSet.Tables' denoted a property where a method was expected

[conehead]
 
That's because you are using C# not VB.NET - you'll have to use square brackets.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I found the solution and it actually should be:

Code:
commentsDS.Tables["table"].Rows[l]["column"].ToString();

Thanks for your help...

[conehead]
 
Yes, that's another method that will work as does the method I provided


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top