Http://blog.sina.com.cn/s/blog_562af3d10100ar4j.html
The most recent project is to write a from program, and the data manipulation is all about dealing with Oracle ...
This can be tiring, as you all know, this machine does not install Oracle clients, this machine program is unable to access the Oracle database.
However, a client can be at least 80 trillion more. It's too big. More, the program deployment is not convenient.
Finding besides on the Internet really has a solution. Ecstasy..... It's not a good thing. Finally proved to be not very useful ...
Finally in the network and colleagues of the joint efforts. Finally, the test was successful.
The method is as follows: (Environment: VS2003+ORACLE10G)
1, the Instantclient-basic-win32-10.2.0.4.zip in the file to the specified location (I am the machine is extracted to D:/fox, and named: instantclient)
The inner surface should include: Basic_readme, Oci.dll, Ocijdbc10.dll, Ociw32.dll, Orannzsbb10.dll, Oraocci10.dll, Oraociei10.dll, Classes12.jar, Ojdbc14.jar nine files.
(Note: Download address: http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html; need to register user, I download is: instantclient-basic-win32-10.2.0.4.zip)
2. Add Tnsnames.ora file (add to d:/fox/instantclient file):
File Tnsnames.ora its contents:
# Tnsnames.ora Network Configuration File:d:/fox/instantclient/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL1 =
(DESCRIPTION =
(Address_list =
(address = (PROTOCOL = TCP) (HOST = server IP or server name) (port = Server port number, defaults to "1521"))
)
(Connect_data =
(service_name = name of server database service, default: "ORCL")
)
)
3, add the contents of the registry: (its contents as follows, the location of the files involved according to their own needs to change)
Windows Registry Editor Version 5.00
[Hkey_local_machine/system/currentcontrolset/control/session Manager/environment]
"Ld_library_path" = "d://fox//instantclient"
"Tns_admin" = "d://fox//instantclient"
"Nls_lang" = "American_america." ZHS16GBK "
4. Add Environment variables
Right-click My Computer--> properties--> "Advanced"--> "Environment variables"--> "System Variables"--> select "Path"--> "edit"--> Add ";D after" variable value ":/fox/ Instantclient "
5, restart the computer (tested, in this order should not be restarted).
6, Query Oracle database part of the code:
Of course this code is the basis of the operation: in this development project--> add references; NET tab, select System.Data.OracleClient.dll.
and add at the beginning of this CS: using system.data.oracleclient;//referencing Oracle connection classes
private void Button8_click (object sender, System.EventArgs e)
{
Try
{
OracleConnection cnn=new oracleconnection ("Data source=orcl1; User id= scheme name; password= password ");
Cnn. Open ();
OracleDataAdapter Myda =new oracledataadapter ();
Myda.selectcommand = new OracleCommand ("SELECT * From/" Table name/", CNN); Table names are enclosed in double quotes when querying
DataSet myDS =new DataSet ();
Myda.fill (myds);
This.textbox1.text=myds.tables[0]. Rows[0][0]. ToString ();//Get the first row of the query table first column
}
catch (Exception ex)
{
MessageBox.Show (ex. message);
}
}
These are my methods for not installing Oracle client databases.