Esempio n. 1
0
        private 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);
            }
        }
Esempio n. 2
0
        private 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);
            }
        }