内容添加asp.net
程序员文章站
2023-11-17 18:59:10
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();
}
}
}
{
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();
}
}
}
上一篇: repeater分页 内容显示
下一篇: DataReader深入解析:持续更新