ASP.NET实现增删改查等功能(Access版)系统之一 -前台及数据库webconfig配置

Web.config配置

appSettings中配置accesssqlserver

<appSettings>

<add key="OleDbConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>

<add key="AccessDbPath" value="App_Data/chinabase.mdb;"/>

<add key="NorthwindConnectionString" value="DataSource=.;database=Northwind;uid=sa;pwd=123"/>

<add key="ChinabaseSQLServerConnectionString" value="Data Source=808644DA83B446C/SQLEXPRESS;Initial Catalog=ChinabaseSQLServer;Persist Security Info=True;User ID=sa;Password=123"/>

</appSettings>

前台页面:

<asp:GridView ID="GridView1" AutoGenerateColumns="false"  OnRowEditing="GridView1_RowEditing"

                        OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit"

        EmptyDataText="No records found" CellPadding="0" CellSpacing="0"  

             Font-Size="11pt"  HeaderStyle-Font-Size="12pt" EditRowStyle-Font-Size="11pt"

        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"

        OnRowDataBound="GridView1_RowDataBound2" runat="server" Width="980px" 

             PageSize="2" AllowPaging="True" AllowSorting="True"  OnSorting="gridViewPublishers_Sorting"

             OnPageIndexChanging="gridViewPublishers_PageIndexChanging"

             onrowdeleting="GridView1_RowDeleting">

                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />

                        <AlternatingRowStyle BackColor="LightGray" />

                        <Columns>

                            <asp:BoundField DataField="id" HeaderText="编号" ReadOnly="True" ItemStyle-Width="40"/>

                           <asp:BoundField DataField="姓名" HeaderText="姓名" ItemStyle-Width="80"  ReadOnly="True" SortExpression="姓名"/>

                            <%--<asp:HyperLinkField HeaderText="姓名" DataTextField="姓名" DataNavigateUrlFields="姓名" Target="mainframe"  DataNavigateUrlFormatString="ResumeAddOrUpdate.aspx?name={0}"  NavigateUrl="ResumeAddOrUpdate.aspx">

                            </asp:HyperLinkField>--%>

                            <asp:BoundField DataField="性别" HeaderText="性别" ItemStyle-Width="80" ReadOnly="True"/>

                            <asp:BoundField DataField="出生日期" HeaderText="出生日期" ReadOnly="True"  ItemStyle-Width="80"/>

  <asp:BoundField DataField="工作年限" HeaderText="工作年限"  ItemStyle-Width="80"/>

  <asp:BoundField DataField="证件类型" HeaderText="证件类型"  ItemStyle-Width="80"/>

  <asp:BoundField DataField="证件号" HeaderText="证件号"  ItemStyle-Width="60"/>

  <asp:BoundField DataField="居住地" HeaderText="居住地"   ItemStyle-Width="60"/>

  <asp:BoundField DataField="Email" HeaderText="Email"   ItemStyle-Width="60"/>

  <asp:BoundField DataField="手机号码" HeaderText="手机号码"  ItemStyle-Width="80"/>

  <asp:BoundField DataField="家庭电话" HeaderText="家庭电话"  ItemStyle-Width="80"/>

  <asp:BoundField DataField="自我评价" HeaderText="自我评价"  ItemStyle-Width="80"/>

  <asp:HyperLinkField HeaderText="编辑" Text="编辑" DataNavigateUrlFields="姓名" Target="mainframe"  DataNavigateUrlFormatString="ResumeAddOrUpdate.aspx?name={0}"  NavigateUrl="ResumeAddOrUpdate.aspx">

 </asp:HyperLinkField>

 <%--<asp:CommandField HeaderText="编辑" ShowEditButton="True"></asp:CommandField>--%>

 <asp:CommandField HeaderText="删除" ShowDeleteButton="True"></asp:CommandField>

 </Columns>

 <RowStyle ForeColor="#8C4510" BackColor="#FFF7E7" />

  <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />

  <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />

  <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />

 </asp:GridView>

/// <summary>

    /// 获得连接Access数据库的字符串

    /// </summary>

    /// <returns></returns>

    public static String GetConnection()

    {

        System.Web.UI.Page page = new System.Web.UI.Page();

        String conn = ConfigurationSettings.AppSettings["OleDbConnectionString"].ToString() + page.Server.MapPath("~/" + ConfigurationSettings.AppSettings["AccessDbPath"].ToString());

        return conn;

    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值