连接本地Oracle数据库的连接字符串怎么写?
数据库名:TESTDB
用户:chbo
密码:admin

解决方案 »

  1.   


    OLE DB, OleDbConnection (.NET) 
    "Provider=msdaora;Data Source=TESTDB;User Id=chbo;Password=admin;" OracleConnection (.NET) 
    "Data Source=TESTDB;User Id=chbo;Password=admin;Integrated Security=no;"
      

  2.   

    OLE DB, OleDbConnection (.NET) 
    "Provider=msdaora;Data Source=TESTDB;User Id=chbo;Password=admin;" OracleConnection (.NET) 
    "Data Source=TESTDB;User Id=chbo;Password=admin;Integrated Security=no;"再加个ODBC的
    "Driver={Microsoft ODBC for Oracle};Server=TESTDB;Uid=chbo;Pwd=admin;" 如果连接远程的,直接吧Data Source改成IP地址就行了,Oracle好像没有库的概念
      

  3.   

    参见: http://www.connectionstrings.com/
    ODBC 
    New version 
      
    Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword; 
     
    Old version 
      
    Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword; 
     
    OLE DB, OleDbConnection (.NET) 
    Standard security 
    This connection string uses a provider from Microsoft.  
    Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword; 
     
    Standard Security 
    This connection string uses a provider from Oracle.  
    Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword; 
     
    Trusted Connection 
      
    Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1; 
     
    OracleConnection (.NET) 
    Standard 
      
    Data Source=MyOracleDB;Integrated Security=yes; 
     
    This one works only with Oracle 8i release 3 or later  
     
    Specifying username and password 
      
    Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no; 
     
    This one works only with Oracle 8i release 3 or later  
    Missing the System.Data.OracleClient namespace? Download .NET Managed Provider for Oracle >> 
    Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner >> 
       
    Omiting tnsnames.ora 
    This is another type of Oracle connection string that doesn't rely on you to have a DSN for the connection. You create a connection string based on the format used in the tnsnames.ora file without the need to actually have one of these files on the client pc.  
    SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword; 
     
      
    Core Labs OraDirect (.NET) 
    Standard 
      
    User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0; 
     
     
    Data Shape 
    MS Data Shape 
      
    Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;User Id=myUsername;Password=myPassword;