国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net連接Access數(shù)據(jù)庫例子

2024-07-10 13:03:07
字體:
供稿:網(wǎng)友
asp.net連接access數(shù)據(jù)庫
<%@ import namespace="system.data" %>
    <%@ import namespace="system.data.oledb" %>
    <script laguage="vb" runat="server">
    dim myconnection as oledbconnection
    dim mycommand as oledbcommand
    sub page_load(sender as object,e as eventargs)

    '1.連接數(shù)據(jù)庫
    dim dbname as string
    dbname=server.mappath("authors.mdb")
    myconnection = new oledbconnection( "provider=microsoft.jet.oledb.4.0;data source="&dbname )
    myconnection.open()
    la1.text="connection opened!"

 

    '2.添加記錄
    mycommand = new oledbcommand( "insert into authors(authors,country) values('simson','usa')", myconnection )
    mycommand.executenonquery()
    la2.text="new record inserted!"

 

    '3 更新數(shù)據(jù)(access)
    mycommand = new oledbcommand( "update authors set authors='bennett' where authors = 'simson'", myconnection )
    mycommand.executenonquery()
    la3.text="record updated!"

 

    '4 刪除數(shù)據(jù)(access)
    mycommand = new oledbcommand( "delete from authors where authors = 'david'", myconnection )
    mycommand.executenonquery()
    la4.text="record deleted!"

 

    '5 使用dategrid顯示數(shù)據(jù)
    mycommand = new oledbcommand( "select * from authors", myconnection )
    mydatagrid.datasource=mycommand.executereader()
    mydatagrid.databind()

 

    end sub
    </script>
    <html>
    <body>
    <asp:label id="la1" runat="server" /><br>
    <asp:label id="la2" runat="server" /><br>
    <asp:label id="la3" runat="server" /><br>
    <asp:label id="la4" runat="server" /><br>
    <asp:datagrid id="mydatagrid" runat="server"
    bordercolor="black"
    borderwidth="1"
    gridlines="both"
    cellpadding="3"
    cellspacing="0"
    font-name="verdana"
    font-size="10pt"
    headerstyle-backcolor="#aaaadd"
    alternatingitemstyle-backcolor="#eeeeee"
    >
    </asp:datagrid>

    </body>
    </html>


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 新沂市| 板桥市| 榆树市| 资兴市| 广安市| 高邑县| 武汉市| 库伦旗| 大同市| 延边| 利川市| 桐城市| 缙云县| 利辛县| 马关县| 韩城市| 盐城市| 垦利县| 宜州市| 云南省| 肥东县| 普安县| 鄂托克前旗| 维西| 诸城市| 泰顺县| 东安县| 佛冈县| 织金县| 阳泉市| 湟中县| 黄龙县| 色达县| 新丰县| 峨眉山市| 水富县| 邯郸市| 砚山县| 昭通市| 宜宾市| 昭通市|