DB Data Select(Oracle)

|

using System;
using System.Collections;
using System.Text;
using System.Data;
using System.Data.OracleClient;


namespace Tran_01
{
    public class OleDbParamTest
    {
        public static void Main()
        {
            string conStr = "Data Source = XE;" +
                "User id = ;" +
                "password = ";
            string Query = "Select * from address where addr = :addr1 or addr = :addr2";
            try
            {
                OracleConnection Oconn = new OracleConnection(conStr);
                Oconn.Open();
                Console.WriteLine("DB 열림");
                OracleCommand cmd = new OracleCommand(Query, Oconn);
                cmd.Parameters.Add("addr1", OracleType.VarChar);
                cmd.Parameters.Add("addr2", OracleType.VarChar);
                cmd.Parameters["addr1"].Value = "seuol";
                cmd.Parameters["addr2"].Value = "Ameria";
                OracleDataReader Odr = cmd.ExecuteReader();
                while (Odr.Read())
                {
                    Console.Write(Odr.GetFloat(0) + "t");
                    Console.Write(Odr.GetString(1) + "t");
                    Console.Write(Odr.GetString(2) + "t");
                    Console.WriteLine();
                }
                Odr.Close();
                Oconn.Close();
            }
            catch (OracleException ErrMsg)
            {
                Console.WriteLine(ErrMsg.Message);
                Console.WriteLine("에러");
            }
        }
    }
}

 

/*

역으로 집어넣는것은 Command.ExecuteNonQuery() 함수 사용 

*/
Trackback 0 And Comment 0
prev | 1 | ··· | 19 | 20 | 21 | 22 | 23 | 24 | next