您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->我的VS2008通讯录项目源码>>Mypb/add.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:我的VS2008通讯录项目源码
当前文件:文件类型 MyPhoneBook/Mypb/add.aspx.cs打开代码结构图
普通视图
		            
1using System.Data.OleDb; 2using System; 3using System.Collections; 4using System.Configuration; 5using System.Data; 6using System.Linq; 7using System.Web; 8using System.Web.Security; 9using System.Web.UI; 10using System.Web.UI.HtmlControls; 11using System.Web.UI.WebControls; 12using System.Web.UI.WebControls.WebParts; 13using System.Xml.Linq; 14 15namespace Mypb 16{ 17 public partial class add : System.Web.UI.Page 18 { 19 protected void Page_Load(object sender, EventArgs e) 20 { 21 this.Title = "添加新纪录"; 22 TextBox1.Focus(); 23 } 24 25 protected void Button2_Click(object sender, EventArgs e) 26 { 27 OleDbConnection conn = new OleDbConnection(); 28 conn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source = " + Server.MapPath("App_Data/Myphonebook.mdb"); 29 //string strVal = TextBox1.Text + "," + TextBox2.Text.ToString() + "," + TextBox3.Text.ToString(); 30 string strVal = "'" + TextBox1.Text +"'," + "'"+ TextBox2.Text + "'," +"'"+ TextBox3.Text+"'"; 31 string strIns = "insert into 通信录(姓名,电话,Email) values(" + strVal + ")"; 32 OleDbCommand insCom = new OleDbCommand(strIns, conn); 33 OleDbDataAdapter da = new OleDbDataAdapter(); 34 conn.Open(); 35 da.InsertCommand = insCom; 36 da.InsertCommand.ExecuteNonQuery(); 37 conn.Close(); 38 Response.Write("<script language=javascript>alert('新纪录添加成功,请单击“返回”回到主页面!');</script>"); 39 } 40 41 protected void Button1_Click(object sender, EventArgs e) 42 { 43 Response.Redirect("default.aspx"); 44 } 45 } 46} 47
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:我的VS2008通讯录项目源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号