I've done it the hard way, now I want to do it the easy way

I've done it the hard way, now I want to do it the easy way

Postby bclayshannon » Wed 28 Mar 2012 16:09

I've got a DataGridView populating with data from a Stored Proc via code. Now, though, I want to do it in a "quick and dirty" way at design time (doesn't have to be with the Stored Proc, could be a Select Query).

I haven't been able to figure out how to do it by playing around, and I haven't come up with any Tutorials on doing this. Supposedly it's quite easy and "Delphi-like" but I need some help.

Does anybody have a link to a Step-by-Step for this?

I simply want to use a Connection, Command, doubtless a DataSet and a DataAdapter, and populate the DataGridView (C# app in VS 2010) with the query results.
bclayshannon
 
Posts: 29
Joined: Wed 14 Mar 2012 18:37
Location: Monterey, California

Postby Pinturiccio » Fri 30 Mar 2012 08:31

I'm posting here a small tutorial "How to populate a DataGridView in design time"

First of all you will need to execute the following script for creating a procedure:
Code: Select all
CREATE OR REPLACE PROCEDURE SCOTT.cur_dept(C_REF OUT SYS_REFCURSOR)
  IS
  BEGIN
    OPEN c_ref FOR SELECT * FROM dept
  END;
END;

Then perform the following steps:
1. Create a Windows Form application;
2. Drag the OracleConnection component from the toolbox to your form. The oracleConnection1 object is created;
3. Specify the ConnectionString;
4. Drag the OracleCommand component from the toolbox to your form. The oracleCommand1 object is created;
5. Chose the oracleConnection1 object as the connection for oracleCommand1;
6. Set the CommandText property of the oracleCommand1 object to the 'cur_dept' value. Or use the query 'select * from dept';
7. Change the CommandType property of the oracleCommand1 object to the StoredProcedure value. Or do noting for a query;
8. Drag the OracleDataTable component from the toolbox to your form. The oracleDataTable1 object is created;
9. Chose the oracleCommand1 object as the SelectCommand property of the oracleDataTable1 object;
10. Select the Active check box of the oracleDataTable1 object.
11. Drag the DataGridView component from the toolbox to your form. The dataGridView1 object is created;
12. Set the value of the DataSource property to "oracleDataTable1" for the dataGridView1 object.

Your DataGridView will be filled in design time.
Pinturiccio
Devart Team
 
Posts: 1852
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for Oracle