well this's my first time in C#, 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.ItemArray["CategoryName"];
//also tried this:
curCat = dstTopics.Tables[0].Rows.ItemArray[0];
}
Here's the error that appears
Cannot implicitly convert type 'object' to 'string'curCat = dstTopics.Tables[0].Rows.ItemArray["CategoryName"].ToString();???well i tried this and same problem (dstTopics.Tables[0].Rows.ItemArray["CategoryName"]).ToString();
or
(string)dstTopics.Tables[0].Rows.ItemArray["CategoryName"];
other than that i'm out of ideas. Google for a working example.it worked when i used
(string)dstTopics.Tables[0].Rows.ItemArray[0];
thankscool, it's just a cast.
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.ItemArray["CategoryName"];
//also tried this:
curCat = dstTopics.Tables[0].Rows.ItemArray[0];
}
Here's the error that appears
Cannot implicitly convert type 'object' to 'string'curCat = dstTopics.Tables[0].Rows.ItemArray["CategoryName"].ToString();???well i tried this and same problem (dstTopics.Tables[0].Rows.ItemArray["CategoryName"]).ToString();
or
(string)dstTopics.Tables[0].Rows.ItemArray["CategoryName"];
other than that i'm out of ideas. Google for a working example.it worked when i used
(string)dstTopics.Tables[0].Rows.ItemArray[0];
thankscool, it's just a cast.