The last time mentioned the basic configuration attention, now started to actually develop problems in Oracle
One Oracle Database connection
But you have installed Oracle's clients, and the database server has been specified when configured, so it is mainly connected to three elements, and the name of the database (ie, the user name, password) is mainly connected.
SqlConnection Con = New SqlConnection ("provider = msdaora.1; user id = userid; data source = xf; password = password")
And SQL Server does not need to install the client, so you must specify the server, and the database name.
SqlConnection con = new SqlConnection ( "workstation id = XIAOFENG; packet size = 4096; user id = sa; integrated security = SSPI; data source = xiaofeng; persist security info = False; initial catalog = xf");
II In Oracle, the function and stored procedures in the package (package).
For example, to run a sql following statement: "select order_no, inventory_part_api.get_description (contract, part_no), part_no from SHOP_ORD where inventory_part_api.get_description (contract, part_no) like '% Lang% 25% jelly' ';
1. In .NET design (such as design SqlDataAdapter) cannot directly use functions and stored procedures in the package. If you want to use, you can declare the function and stored procedure COPY you want to use during the design, and declare it. You can use it
2. Add code directly when .NET runtime, the system will go directly to the content in the package.
String strcommand;
strCommand = "select order_no, inventory_part_api.get_description (contract, part_no), part_no from SHOP_ORD where inventory_part_api.get_description (contract, part_no) like '% 25% Lang jelly%'";
OLEDBCONNECTION Con = New OLEDBCONNECTION ("provider = msdaora.1; password = password; user id = userid; data source = xf");
C.Open ();
OLEDBDataAdapter adapter = new oledbdataadapter (struct, con);
DataSet DataSet = New DataSet ();
Adapter.Fill (Dataset);
this.DataGrid1.datasource = DataSet;
DataGrid1.databind ();
C. close ();
?
3. How to use stored procedures
OracleConnection conn = new OracleConnection ("Data Source = Oracle8i; Integrated Security = YES);
Cn.open;
OracleCommand cmd = conn.createCommand (); cmd.commandtext = "sp_pkg.getdata";
cmd.commandtype = commandtype.storedProcedure;
CMD.Parameters.Add (New OracleParameter). Direction = parameterDirection.output;
Cmd.Parameters.Add (New OracleParameter). Direction = parameterDirection.output;
DataSet DS = New Dataset ();
OracleDataAdapter Adapter = New OracleDataAdapter (CMD);
Adapter.Fill (DS);