1. Create a new WinForm form in VS
(1) a button
(2) A Data table view (the data table displayed inside)
2. Double-click the button to enter the code
(1) adding using System.Data.OracleClient;
If you are not prompted to find Oracle, the Toolbox is not available by default, toolbox--right--Select items--. NET Framework Components
I've added all the Oracle fields to the Toolbox,
(2) Automatically eject the "Data Adapter Configuration Wizard" is to configure the properties of your database connection,
The last one doesn't know what it means, I wrote a SELECT statement just like the SQL statement in the button event code
And then the following,
Solution Explorer--Programs--references--with System.Data.OracleClient,
See Using System.Data.OracleClient; I don't have an error.
Alternatively: Right-click on the reference, add Reference, add System.Data.OracleClient
(3) button event code
Private voidButton1_Click (Objectsender, EventArgs e) { stringconnectionString; stringqueryString; ConnectionString="Data SOURCE=ORCL; User Id=scott; Password=tiger"; QueryString="SELECT * from TEST"; OracleConnection myconnection=NewOracleConnection (connectionString); OracleCommand mycommand=Myconnection.createcommand (); myCommand.CommandText=queryString; Myconnection.open (); OracleDataAdapter Orada=NewOracleDataAdapter (mycommand); DataSet DS=NewDataSet (); Orada.fill (DS); Myconnection.close (); DataTable Dtbl=ds. tables[0]; This. Datagridview1.datasource =dtbl; }
(4) operation, the results are as follows:
As with the data in my database
Visual Studio 2013 connects to Oracle 11g and gets data: (ii: Implementation)