內(nèi)容添加asp.net
更新時間:2006年10月13日 00:00:00 作者:
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="出現(xiàn)錯誤";
}
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="出現(xiàn)錯誤";
}
finally{
conn.Close();
}
}
}
相關(guān)文章
在ASP.NET 2.0中操作數(shù)據(jù)之四:使用ObjectDataSource展現(xiàn)數(shù)據(jù)
前面介紹搭建基礎(chǔ)的架構(gòu),下面我們來介紹ASP.NET中,如何利用ObjectDataSource來展現(xiàn)數(shù)據(jù)。通過配置ObjectDataSource,我們指定這些底層的對象,還有這些對象的方法如何映射到ObjectDataSource的Select、Insert、Update和Delete方法。2016-04-04
在ASP.NET 2.0中操作數(shù)據(jù)之十五:在GridView的頁腳中顯示統(tǒng)計信息
本文主要介紹在GridView中顯示頁腳的實現(xiàn)方法,通過設(shè)置ShowFooter設(shè)置為True,再配合事件和底層的方法從而實現(xiàn)在GridView的頁腳區(qū)域顯示相關(guān)的統(tǒng)計信息。2016-05-05
在ASP.NET 2.0中操作數(shù)據(jù)之二十四:分頁和排序報表數(shù)據(jù)
本文主要介紹ASP.NET 2.0中使用GirdView控件呈現(xiàn)數(shù)據(jù)時如何實現(xiàn)分頁和排序功能的,希望對大家有所幫助。2016-05-05
解讀ASP.NET 5 & MVC6系列教程(7):依賴注入
這篇文章主要介紹了ASP.NET 5 依賴注入,需要的朋友可以參考下2016-06-06
使用.Net6中的WebApplication打造最小API
本文詳細講解了使用.Net6中的WebApplication打造最小API,文中通過示例代碼介紹的非常詳細。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-12-12
在ASP.NET 2.0中操作數(shù)據(jù)之五十七:在分層架構(gòu)中緩存數(shù)據(jù)
上一篇文章我們介紹了ASP.NET 2.0中使用ObjectDataSource在視圖層緩存數(shù)據(jù),缺點是不言而喻的,為了達到低耦合,本文介紹如何在三層架構(gòu)中使用緩存技術(shù)來緩存數(shù)據(jù)。2016-05-05

