不裝 Oracle client 用 C# 連Oracle
from https://www.nuget.org/packages/oracle.manageddataaccess/
ODP.NET, Managed Driver is a 100% native code .NET Framework driver for Oracle Database. No additional Oracle Client software is required to be installed to connect to Oracle Database.
public static String ConnectionString = "Data Source=1.7.1.2:1121/AADB;Persist Security Info=True;User ID=USER;Password=456";
public static void QueryInfo(string someName)
{
try
{
using (var conn = new OracleConnection(EDAConnectionString))
{
conn.Open();
String sql = @"SELECT TABLENAME FROM TABLE1
where TABLENAME=:TABLENAME";
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.Parameters.Add(new OracleParameter("NAME", someName));
using (OracleDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
table.LastIndex = Decimal.Parse(reader["LASTINDEX"].ToString());
}
}
}
}
catch (Exception ex)
{
LogError("1", ex.Message);
throw;
}
return table;
}
留言
張貼留言