예제 #1
0
    static void Main(string[] args)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;

        using (SqlConnection sqlCon = new SqlConnection(connectionString))
        {
            sqlCon.Open();

            MemberInfoDAC dac = new MemberInfoDAC(sqlCon);

            DataRow newItem = dac.NewRow();
            newItem["Name"]   = "Jennifer";
            newItem["Birth"]  = new DateTime(1985, 5, 6);
            newItem["Email"]  = "*****@*****.**";
            newItem["Family"] = 0;
            dac.Insert(newItem);

            newItem["Name"] = "Jenny";
            dac.Update(newItem);

            DataSet ds = dac.SelectAll();

            foreach (DataRow member in ds.Tables["MemberInfo"].Rows)
            {
                Console.WriteLine(member["Email"]);
            }

            dac.Delete(newItem);
        }
    }
예제 #2
0
    static void Main(string[] args)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;

        MemberInfo item = new MemberInfo();

        item.Name   = "Jennifer";
        item.Birth  = new DateTime(1985, 5, 6);
        item.Email  = "*****@*****.**";
        item.Family = 0;

        using (SqlConnection sqlCon = new SqlConnection(connectionString))
        {
            sqlCon.Open();

            MemberInfoDAC dac = new MemberInfoDAC(sqlCon);
            dac.Insert(item); // 신규 데이터를 추가하고

            item.Name = "Jenny";
            dac.Update(item);                    // 데이터 내용을 업데이트하고

            MemberInfo[] list = dac.SelectAll(); // 데이터를 조회하고

            foreach (MemberInfo member in list)
            {
                Console.WriteLine(member.Email);
            }

            dac.Delete(item); // 데이터를 삭제한다.
        }
    }