How do you make use of the generated ROW classes?

How do you make use of the generated ROW classes?

Postby betawarz » Mon 06 Dec 2010 18:24

Hi all,

I'm using the dotConnect for Oracle drivers in my C# application. I've got my Table Adapter working, and executing a custom query of mine. I'm able to see the results, in code, by looping over the Rows DataRowCollection object.

But, I see that there is a provided Row class - in my case USERSRow. I'm trying to figure out how to use this class with the results from the query. This would be nice so I can reference the columns by property name rather than an obscure index value in the DataRowCollection array.

How do I make use of this class? Here's my small chunk of code. Thanks in advance!

Code: Select all
            // Perform the query
            USERSTableAdapter usersAdapter = new USERSTableAdapter();
            DataArchive.USERSDataTable usersTable = usersAdapter.GetData(this.Username.Text, this.Password.Text);

            if (usersTable.Rows.Count == 1)
            {
                // Successfull login attempt
            }
betawarz
 
Posts: 10
Joined: Mon 06 Dec 2010 18:15

Postby Shalex » Wed 08 Dec 2010 12:57

usersTable.Rows returns DataRowCollection, and you can refer to DataRowCollection's items (DataRows) via indexer: usersTable.Rows[i] where i is a number of a DataRow in this collection. When you have got a particular row, you can reference the needed column via its index or column name: usersTable.Rows[i]["COLUMN_NAME_IN_TABLE_USERS"].
MSDN: http://msdn.microsoft.com/en-us/library/system.data.datatable.rows.aspx.
Code: Select all
            // Perform the query
            USERSTableAdapter usersAdapter = new USERSTableAdapter();
            DataArchive.USERSDataTable usersTable = usersAdapter.GetData(this.Username.Text, this.Password.Text);

            if (usersTable.Rows.Count > 0) {
                // Successfull login attempt
                for (int i = 0; i < usersTable.Rows.Count; i++) {
                    Console.WriteLine(usersTable.Rows[i]["COLUMN_NAME_IN_TABLE_USERS"]);
                }
                Console.ReadLine();
            }


Be aware that there are two possible ways to generate DataSet with dotConnect for Oracle:
1) Microsoft DataSet generation (the Data > Add New DataSource menu of Visual Studio) - standard way with TableAdapters classes;
2) Devart DataSet generation (the Tools > Oracle > DataSet Wizard menu of Visual Studio) - the way based on the extended capabilities of the OracleDataTable class (without TableAdapters classes): http://www.devart.com/dotconnect/oracle/docs/?DataSets.html.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle