Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataView/DataSet/DataReader
Message
From
09/01/2007 15:10:22
John Baird
Coatesville, Pennsylvania, United States
 
 
To
09/01/2007 15:01:18
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01183234
Message ID:
01183929
Views:
35
>>>>I think this is related because this is not a datarow. I would suggest you use a datarow as you will be able to deal directly with the content of the field as is.
>>>>
>>>>As soon as you have a dataset, you can scroll into it like this:
>>>>
>>>>
>>>>        For lnCounter = 0 To lnYourRecordCountOfTheDataSetHere
>>>>            loRow = loDataProvider.oDataSet.Tables(YourAlias).Rows(lnCounter)
>>>>            lnAmount = loRow("MaxOrdAmt")
>>>>        Next
>>>>
>>>
>>>
>>>Hi Michel.
>>>I'm playing with the following piece of code.
>>>
>>>
>>>using System;
>>>using System.Text;
>>>using System.Data;
>>>using System.Data.OleDb;
>>>
>>>namespace MyPlayCode
>>>{
>>>    class Program
>>>    {
>>>        static void Main(string[] args)
>>>        {
>>>            string ConnectionString = @"Provider=VFPOLEDB;Data source=C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data\testdata.dbc;";
>>>
>>>            string CommandString = "SELECT * FROM customer where country = 'USA'";
>>>
>>>            OleDbDataAdapter DataAdapter = new OleDbDataAdapter(CommandString, ConnectionString);
>>>
>>>            DataSet sDataSet = new DataSet();
>>>
>>>            DataAdapter.Fill(sDataSet);
>>>
>>>            DataTable DTable = sDataSet.Tables[0];
>>>            int nMaxAmt = 0;
>>>
>>>            string sDispStr = "";
>>>            foreach (DataRow TRow in DTable.Rows)
>>>            {
>>>                sDispStr += TRow[0] + ", " + TRow[1] + " – " + TRow[2] + TRow[11].ToString() + "\n";
>>>                Console.WriteLine(sDispStr);
>>>                Console.ReadLine();
>>>
>>>            }
>>>
>>>        }
>>>    }
>>>}
>>>
>>>
>>>I think I setup the DataAdpater correctly. But I want to access my field by field name like TRow("custname") or TRow("MaxOrdAmt") like you.
>>>
>>>How do I get there from this code? Am I close?
>>>
>>>Thanks.
>>
>>sDispStr += TRow["field1"].ToString() + ", " + TRow["field2"].ToString() + " – " + TRow["field3"].ToString() + TRow["field4"].ToString() + "\n";
>
>huh?
>Must I convert everything to STRING first?


No... there is an implicit cast from object to string....
Previous
Reply
Map
View

Click here to load this message in the networking platform