コード例 #1
0
        public bool savePage(PageItem item)
        {
            string        insertSQL = string.Format("INSERT INTO XueBa.dbo.WebPage(wid,title,author,postdate,link,referred,views,rate) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','0','0')", item.getwid(), item.gettitle(), item.getauthor(), item.getpostdate(), item.getlink(), item.getreferred());
            SqlConnection con       = Connection.instance(AppConfiguration.GetConfigValue("serverIp"), "crawler", AppConfiguration.GetConfigValue("username"), AppConfiguration.GetConfigValue("password"));
            SqlCommand    Command   = con.CreateCommand();

            Command.CommandText = insertSQL;
            try
            {
                Command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);

                return(false);
            }
            con.Close();
            return(true);
        }