Cipher
10-23-2005, 03:00 PM
well this's my first time in C#, i'm currently using VB.NET, so how can i get items from DataSet, here's the VB Code:
Dim curCatAs String
For i = 0 To dstTopics.Tables(0).Rows.Count - 1
curCat = dstTopics.Tables(0).Rows(i).Item("CategoryName")
Next
i tried this in C# like this but it didnt work:
string curCat;
for (i = 0; i < dstTopics.Tables[0].Rows.Count; i++) {
curCat = dstTopics.Tables[0].Rows[i].ItemArray["CategoryName"];
//also tried this:
curCat = dstTopics.Tables[0].Rows[i].ItemArray[0];
}
Here's the error that appears
Cannot implicitly convert type 'object' to 'string'
Dim curCatAs String
For i = 0 To dstTopics.Tables(0).Rows.Count - 1
curCat = dstTopics.Tables(0).Rows(i).Item("CategoryName")
Next
i tried this in C# like this but it didnt work:
string curCat;
for (i = 0; i < dstTopics.Tables[0].Rows.Count; i++) {
curCat = dstTopics.Tables[0].Rows[i].ItemArray["CategoryName"];
//also tried this:
curCat = dstTopics.Tables[0].Rows[i].ItemArray[0];
}
Here's the error that appears
Cannot implicitly convert type 'object' to 'string'