1.选择“Microsoft ODBC for Oracle”
2.数据源名:连接字符串中的名字 / 用户名: 数据库名字(SID名)/服务器名:数据库服务器IP地址
using System.Data.Odbc;
private void MonitorBatch()
{
string contection = "DSN=DSN_NAME;UID=USERNAME;Pwd=PASSWORD;"
OdbcConnection conn = new OdbcConnection(contection);
try
{
conn.Open();
string sql = @"SELECT SEND_DATE, SEND_STS FROM MASTER WHERE SEND_DATE < to_char(sysdate,'yyyymmdd') AND SEND_STS = '0' AND ID < ? ORDER BY SEND_DATE ";
OdbcCommand command = conn.CreateCommand();
command.CommandText = sql;
command.Parameters.Add("", OdbcType.Int).Value = 100;
OdbcDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine(reader.GetString(0) + " " +reader.GetString(1));
}
}
command.Dispose();
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message)
} finally {
conn.Close();
}
}