欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

内容添加asp.net

程序员文章站 2022-06-29 19:05:47
private void button1_click(object sender, system.eventargs e)...
private void button1_click(object sender, system.eventargs e)
        {
            if(this.isvalid){
            oledbconnection conn=dbconn.createconn();
                conn.open();
                oledbcommand cmd=new oledbcommand();
                cmd.commandtext="insert into a(title,content)values('"+this.title.text.trim().replace("'","")+"','"+this.content.text.trim().replace("'","")+"')";
                cmd.connection=conn;
                try
                {
                    cmd.executenonquery();
                    this.title.text="";
                    this.content.text="";
                    this.add_info.text="提交成功";
                }
                catch
                {
                    this.add_info.text="出现错误";

                                    }
                finally{
                conn.close();
                }
            }
        }