public void Insert(User user)
 {
     //Console.WriteLine("在SQL SERVER中给User表增加一条记录");
     //创建SqlConnection对象
     //拼接SQL命令 INSERT INTO USER VALUES('{0}','{1}') , user.ID, user.Name
     //创建SqlCommand对象
     //调用SqlCommand对象的.ExecuteNonQuery()
 }
Пример #2
0
        private static void Main(string[] args)
        {
            User user1 = new User();
            user1.ID = 1;
            user1.Name = "Tom";

            User user2 = new User();
            user2.ID = 2;
            user2.Name = "Jane";

            SqlserverUser su = new SqlserverUser();
            su.Insert(user1);
            su.Insert(user2);

            User resultUser1 = su.GetUser(1);
            User resultUser2 = su.GetUser(2);

            Console.ReadLine();
        }