asp修改数据实例(asp增删改查)

虚拟屋 2022-12-21 09:39 编辑:admin 282阅读

1. asp增删改查

visual studio是开发软件程序的编辑器(IDE),可开发C#、ASP之类的程序,在开发过程中,支持连接数据库对数据进行增删改查等的操作。

2. ASP增删改查代码

string str1 = "insert into user1 values('" + this.TextBox1.Text.Trim() + "','" + this.TextBox11.Text.Trim() + "','" + this.TextBox2.Text.Trim() + "','" + this.DropDownList1.SelectedValue + "','" + this.RadioButtonList1.SelectedItem.Text + "','" + this.TextBox10.Text.Trim() + "','" + this.TextBox9.Text.Trim() + "','" + filename1 + "')"; SqlCommand cmd1 = new SqlCommand(str1, con1);

3. asp.net web连接数据库增删改查

form标签中有一个action属性,该属性的作用是:提交表单后,将表单数据发送到指定位置“login”

asp后边是处理数据的,比如你要登录,登陆需要密码和用户名,这个action把你的用户名和密码交给form_action.asp这样的话你用户名和密码交到后台,后台就去查你的用户名对不对,密码对不对,如果用户名密码对的话就登陆进入页面,不对的话就在页面上提示你错误,验证之后再登陆.简单地说,这个asp就是根据你在页面上的业务,来处理你业务的,包括数据的增删改查

4. ASP增删改查实验报告

web版的学生管理系统,有这么几步要走:

1.首先确定架构,如果您要用C#,那么注定是Windows+IIS+asp.net+mssql了。至于版本我就不写了,您自己确定。

2.开发的时候,是否考虑使用框架,或者彩什么样的开发架构,三层,还是不分层。分与不分都各有特色,如果是你一个人来开发,建议还是不要分了。

3.把要实现的功能列出来,并建好数据库表,并根据数据库表,考虑相应的增删改查功能。通常数据库都是这些功能的。面向数据库的开发,这个思路就对了。

4.再就是相应的界面了,根据功能和权限等,设置相应的界面,并控制好输入输出的交互。

做好后,发布上传到服务器,便可以使用。

5. asp修改数据库

前台是纯html+css,与用不用dreamwear无关。你用dreamwear打开也行。后台是asp,可以登录管理,默认密码是12345,数据库是data里面那个,改扩展名为mdb可以用access打开。我做的时候,为了和其它程序整合,所以分开了,你自己有兴趣可以整合成一个文件。

6. asp实现sql增删查改

伴随着微软的开源和跨平台,学习C# .net的人也是越来越多了,C# .net在很多方面都有应用,桌面应用,有winform 和 wpf, web 开发方面,有 asp.net mvc,游戏开发方面,有 unity 3D, 如今asp .net core 也可以跨平台了,也可以在linux服务器上运行,并不依赖于.net framework。在国外从事.net开发的人还是挺多的,国内的话,.net高手,没有其他编程语言多,个人感觉。

想学好C# .net,你首先要有编程的兴趣,如果没有兴趣的支撑,任何事情都是学不好的,因为你不可能持久的去做这件事。而编程却是要时刻保持学习的状态,不然会被淘汰的。任何一门编程语言,学好它的第一步就是要了解他的语言基础,比如他的语言规范,可以先去看视频或者相关的书籍,做好第一步功课之后,可以尝试用C# .net 写一些小的应用,比如说实现一个计算器之类的;等到这些都满足不了你的时候,你可以尝试写一些跟数据库相关的操作,比如实现一个简单的XX管理系统之类的,有简单的增删查找,等到这些都满足不了你的时候,你可以向web开发迈近,web开发要学习的东西真的挺多的,比如说前端要学一点html,css,jquery也要会,后台sqlserver 数据库,多表查询。我觉得学习最主要的要把基础打牢固。举个例子,比如说数据库的操作,Dataset 与datareader 有什么区别,访问数据库相关的几个类,分别是什么意思。.net底层也应该要有所了解,建议看看CLR via C# ,这是本不错的书,看个几遍很有意思。

最后的建议,实践才是学习的最佳途径。所以我的建议是如果你有条件,你可以找个小的公司进去实习,边实习边学习,这样的进步最大。因为你会有个压力迫使你去学习,不然你什么都不会很尴尬的。而且实习的过程中可以向优秀的人学习,这样你会学到很多,不仅仅是知识,更多的是经验。最后希望对有心入这一行的人能够有帮助。

7. asp.net mvc增删改查

我的一个GridView操作文件,数据源是实体LIST,删改查功能都有了,你参考下 using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using lwf_MVC.CTRL; using lwf_MVC.lwf_Normal; using lwf_MVC.MODEL; public partial class admin_news_edit : System.Web.UI.Page { public string icls_name = "cls_f_news"; //不同级数系列区别在于iWhere public string iWhere = " 1 = 1 and ENG = " + WEB.GQ("ENG", "0") + " and TID1 = " + WEB.GQ("SSS", "1") + " and 1 = 1"; public int getRecordCount() { cls_f_news if_news = (cls_f_news)CTRL.CreateModel(icls_name); if_news.title = soKey.Text; if_news.contents = soKey.Text; if_news.WHERE = iWhere; int i_recordcount = CTRL.getCount(if_news, "order by orderid,id desc"); return i_recordcount; } protected void Page_Load(object sender, EventArgs e) { if (WEB.getSession("userName") == null || WEB.getSession("userName") == "") JS.RD(System.Web.HttpUtility.UrlDecode("%e7%99%bb%e9%99%86%e8%b6%85%e6%97%b6%2c%e8%af%b7%e9%87%8d%e6%96%b0%e7%99%bb").Trim(), "../login.aspx"); if (!IsPostBack) { AspNetPagerBin(1); GridViewBin(); } } protected void AspNetPagerBin(int curr) { int i_recordcount = getRecordCount(); AspNetPager1.RecordCount = i_recordcount; AspNetPager1.CurrentPageIndex = curr; } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; GridViewBin(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; GridViewBin(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int i_id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); baseTableObj.title = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString(); baseTableObj.newfrom = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text.ToString(); baseTableObj.addTime = DateTime.Parse(((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text.ToString()); baseTableObj.orderid = int.Parse(((TextBox)GridView1.Rows[e.RowIndex].FindControl("tb_orderid_b")).Text.ToString()); if (CTRL.Update(baseTableObj)) { JS.alert(System.Web.HttpUtility.UrlDecode("%e4%bf%ae%e6%94%b9%e6%88%90%e5%8a%9f").Trim()); } else { JS.alert(System.Web.HttpUtility.UrlDecode("%e7%bd%91%e7%bb%9c%e8%b6%85%e6%97%b6%ef%bc%8c%e8%af%b7%e9%87%8d%e6%96%b0%e5%86%8d%e8%af%95").Trim()); } //==================================== GridView1.EditIndex = -1; GridViewBin(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int i_id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); if (CTRL.Delete(baseTableObj)) { JS.alert(System.Web.HttpUtility.UrlDecode("%e8%ae%b0%e5%bd%95%e5%88%a0%e9%99%a4%e6%88%90%e5%8a%9f").Trim()); } else { JS.alert(System.Web.HttpUtility.UrlDecode("%e7%bd%91%e7%bb%9c%e8%b6%85%e6%97%b6%ef%bc%8c%e8%af%b7%e9%87%8d%e6%96%b0%e5%86%8d%e8%af%95").Trim()); } //==================================== GridView1.EditIndex = -1; GridViewBin(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { GridView1.EditIndex = -1; GridView1.PageIndex = AspNetPager1.CurrentPageIndex; GridViewBin(); } protected void CheckBox_all_CheckedChanged(object sender, EventArgs e) { CheckBox_opp.Checked = false; for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (CheckBox_all.Checked) { ckb.Checked = true; } else { ckb.Checked = false; } } } protected void CheckBox_opp_CheckedChanged(object sender, EventArgs e) { CheckBox_all.Checked = false; for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (ckb.Checked) { ckb.Checked = false; } else { ckb.Checked = true; } } } protected void lb_delete_Click(object sender, EventArgs e) { for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (ckb.Checked) { int i_id = int.Parse(GridView1.DataKeys[i_i].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); CTRL.Delete(baseTableObj); } } int i_Pcount = getRecordCount(); if (AspNetPager1.CurrentPageIndex > i_Pcount) { AspNetPagerBin(i_Pcount); } else { AspNetPagerBin(AspNetPager1.CurrentPageIndex); } GridViewBin(); } protected void lb_order_Click(object sender, EventArgs e) { for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { TextBox tb = (TextBox)GridView1.Rows[i_i].FindControl("tb_orderid_a"); int i_id = int.Parse(GridView1.DataKeys[i_i].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); baseTableObj.orderid = int.Parse(tb.Text.ToString()); CTRL.Update(baseTableObj); } GridViewBin(); } protected void bt_search_Click(object sender, EventArgs e) { AspNetPagerBin(1); GridViewBin(); } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowNum; int id_i; } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { } } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; ViewState["sortExpression"] = sortExpression; if (ViewState["ASC"].ToString() == "0") { ViewState["ASC"] = "1"; } else { ViewState["ASC"] = "0"; } AspNetPagerBin(1); GridViewBin(); } protected void GridViewBin() { CheckBox_all.Checked = false; cls_f_news if_news = (cls_f_news)CTRL.CreateModel(icls_name); if_news.title = soKey.Text; if_news.contents = soKey.Text; if_news.WHERE = iWhere; int RecordCount; int curP = Convert.ToInt32(AspNetPager1.CurrentPageIndex); List<cls_f_news> iList_f_news = CTRL.getPageList(if_news, "order by orderid,id desc", AspNetPager1.PageSize, curP, out RecordCount).ConvertAll<cls_f_news>(delegate(lwf_MVC.MODEL.baseTable s) { return (cls_f_news)s; }); if (ViewState["ASC"] == null) ViewState["ASC"] = "-1"; if (ViewState["sortExpression"] == null) ViewState["sortExpression"] = "orderid"; if (ViewState["ASC"].ToString() == "-1") { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null), b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null)); }); } else { if (ViewState["ASC"].ToString() == "1") { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null), b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null)); }); } else { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null), a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null)); }); } } GridView1.DataSource = iList_f_news; GridView1.DataKeyNames = new string[] { "id" }; GridView1.DataBind(); } }