Exemple #1
0
        void Button1_Click(object sender, EventArgs e)
        {
            njh.sys.DAL.MySqlHelper db = new njh.sys.DAL.MySqlHelper();
            //DataTable dt = db.ExecDataTable("select * from companyinfo");
            //Response.Write(dt.Rows.Count);

            //string s = Helper.Serialize.BinaryHelper<DataTable>.ToString(dt);
            //StreamWriter sw = new StreamWriter("d:\\dt.bin");
            //sw.Write(s);
            //sw.Close();

            StreamReader sr = new StreamReader("d:\\dt.bin");
            string s = sr.ReadToEnd();
            DataTable dt = Helper.Serialize.BinaryHelper<DataTable>.ToObject(s);
            Response.Write(dt.Rows.Count);
            string ss = "", sql = "";
            MSAccessHelper dbs = new MSAccessHelper("d:\\company.mdb");
            try
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string guid = dr["guid"].ToString();
                    ss = guid;
                    int classid = 0;
                    string tag = "";
                    string companyname = dr["companyname"].ToString();
                    string tel = dr["tel"].ToString();
                    string contact = dr["contact"].ToString();
                    string qq = dr["qq"].ToString();
                    string email = dr["email"].ToString();
                    string url = dr["url"].ToString();
                    string jyfw = dr["jyfw"].ToString();
                    string jianjie = "";
                    string province = dr["province"].ToString();
                    string city = dr["city"].ToString();
                    int click = 0;
                    string sourceurl = dr["sourceurl"].ToString();
                    int isinfo = 0;
                    int issend = 0;
                    string clsaanem1 = dr["classname1"].ToString();
                    string clasnanme2 = dr["classname2"].ToString();
                    string address = dr["address"].ToString();
                    sql = "insert into companyinfo([guid],classid,tag,companyname,tel,contact,qq,email,url,jyfw,province,city,click,sourceurl,isinfo,issend,classname1,classname2,address)";
                    sql += "values('" + guid + "'," + classid + ",'" + tag + "','" + companyname + "','" + tel + "','" + contact + "','" + qq + "','" + email + "','" + url + "','" + jyfw + "','" + province + "','" + city + "',0,'" + sourceurl + "',0,0,'" + clsaanem1 + "','" + clasnanme2 + "','" + address + "')";
                    dbs.ExecuteNonQuery(sql);
                }

            }
            catch (Exception ee)
            {

                StreamWriter sw = new StreamWriter("d:\\0.txt");
                sw.Write(sql);
                sw.Close();
                throw new Exception(ss + sql + "<br>" + ee.Message);
            }
        }
Exemple #2
0
        void Button1_Click(object sender, EventArgs e)
        {
            MSAccessHelper db = new MSAccessHelper(Server.MapPath("dtcms.mdb"));

            string s = NjhLib.Utils.FileUtil.GetHtmlStringByFilePath(Server.MapPath("1.htm"));
            s = Server.HtmlEncode(s);
               // Response.Write("开始时间:" + DateTime.Now.ToString());
            for (int i = 0; i < 100000; i++)
            {
                TextBox1.Text = "insert begin:" + DateTime.Now + "\r" + TextBox1.Text;
                TextBox1.Text = "now :" + i.ToString() + "\r" + TextBox1.Text;
                string sql = " insert into article(title ,author,form,keyword,zhaiyao,classid,imgurl,daodu,content,click,ismsg,istop,isred,ishot,isslide,islock,addtime) ";
                sql += "values('项目背景说明及系统开发要求" + i.ToString() + "','author','form','keyword.keyword','zhaiyaozhaiyaozhaiyaozhaiyaozhaiyaozhaiyao',1,'','daodudaodudaodudddddddddddddddddddddddddddddddddd','" + s + "',1,1,1,1,1,1,0,'" + DateTime.Now.ToString() + "')";
                db.ExecuteNonQuery(sql);

            }
            TextBox1.Text = "insert end:" + DateTime.Now.ToString() + "\r" + TextBox1.Text;
            //Response.Write("结束时间:" + DateTime.Now.ToString());
            Response.Write("<script>alert('insert suc')</script>");
        }