使用微软自带的oracle连接类,在framework4.0中被标识为弃用,强行用它开发了Winform程序,发布放到XP上提示:
Error System.Data.OracleClient requires Oracle client software version 8.1.7 or greater when installs setup
最后还是换成Oracle的组件解决,记录一下步骤
1, http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html
选择
- 64-bit ODAC Downloads - Oracle Universal Installer and Xcopy
2, http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
下载:ODP.NET_Managed_ODAC12cR4.zip - 2.57 MB
3,解压并在dos运行命令
install_odpm.bat c:oracle x64 false
4, 在项目中找到添加引用
C:oracleodp.netmanagedcommonOracle.ManagedDataAccess.dll
5, Happy Coding
using Oracle.ManagedDataAccess.Client; namespace Util { public class OracleManager : IDBManager { private const string CONNECT_STRING = "Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = {0})(PORT = {1})))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = {2}))); User Id = {3}; Password = {4}"; public string GetConnectString(string dbName, string IP, string user, string pwd, string port) { return String.Format(CONNECT_STRING, IP, port, dbName, user, pwd); } public DbConnection GetConnection(string connectionString) { return new OracleConnection(connectionString); }