コード例 #1
0
 //向数据库写一个作者
 public static void WriteAuthor(int id)
 {
     Author a = GetAuthor(id);
     int result = 0;
     using (AuthorDao dao = new AuthorDao())
         result = dao.add(a);
     Console.WriteLine("已经写入" + result + "个作者");
 }
コード例 #2
0
 //所有作者写到数据库中
 public static void WriteAllAuthor(int begin)
 {
     for (int i = begin; i <= 978; i++)
     {
         Author a = GetAuthor(i);
         int result = 0;
         using (AuthorDao dao = new AuthorDao())
             result = dao.add(a);
         if (result < 0)
             throw new ApplicationException("插入错误");
     }
     Console.WriteLine("数据下载完毕");
 }