5 frontpage+Access資料庫的修改

來源:互聯網
上載者:User

第五部分,frontpage+Access資料庫的修改

現在進入最後一節了,經過幾天的努力我要進入最後的章節了,是在是激動啊。接下來要說的就是如何利用frontpage進行access資料庫中資料的修改了。

第一步,當然也是添加網頁之類的了,著了我就不再詳細複述如何添加了,因為前面幾節都講的十分的清楚了呵呵。這裡就簡單的講下,要建立一個edit.htm網頁,一個edit.asp網頁和一個modify.asp網頁。首先在這裡和大家說下,不好意思,在前面的幾個節裡面有一個地方沒有講清楚,就是資料庫的裡面,先不要有自動編號的那一欄,有的可以重新刪掉,然後重新添加下資料庫就可以了,這個很快的。

按上面說的建完網頁:

Edit.htm代碼如下:

<body>

<form name="form1" method="post" action="edit.asp">

請輸入要修改的學號: 

<input type="text" name="id"> 

<br> 

<input type="submit" name="submit" value="提交"> 

</form> 

 

 </body> 

Edit.asp代碼如下(這些多虧了網友的熱熱心協助才有了這個結果啊,我也是個新手,為了大家一起進步才寫的這些內容,希望對大家有協助啊)

<body>

<%

set conn=server.createobject("adodb.connection")

conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("fpdb/lianxi1.mdb")

temp=Request.Form("id")

exec="select * from lianxibiao1 where
學號='"&temp&"'"

set rs=server.createobject("adodb.recordset")

rs.open exec,conn

%>

 

<form name="form1" method="post" action="modify.asp">

<table width="748" border="0" cellspacing="0"
cellpadding="0">

<tr>

      <td height="16"><b>學號</b></td>

      <td height="16"><b>姓名</b></td>

      <td height="16"><b>學習類型</b></td>

      <td height="16"><b>學院</b></td>

      <td height="16"><b>專業</b></td>

      <td height="16"><b>聯絡電話</b></td>

</tr>

<tr>

<td>

<input type="text" name="xuehao" value="<%=rs("學號")%>">

</td>                     

<td>                     

<input type="text" name="xm" value="<%=rs("姓名")%>">                     

</td>                     

<td>                     

<input type="text" name="xuexilx" value="<%=rs("學習類型")%>">                     

</td>                     

<td>                     

<input type="text" name="xueyuan" value="<%=rs("學院")%>">                     

</td>                     

<td>                     

<input type="text" name="zhuanye" value="<%=rs("專業")%>">                     

</td>                     

<td>                     

<input type="text" name="dianhua" value="<%=rs("聯絡電話")%>">                     

</td>                     

</tr>                     

<tr>                     

<td>     

<input type="submit" name="Submit" value="提交">   

                                                         

</tr>                                           

</table>                                           

</form>                       
                    

<%                                           

rs.close                                           

set rs=nothing                                           

conn.close                                           

set conn=nothing                                            

%>                                           

</body> 

 

最後是modify.asp代碼

<body>

<%

set conn=server.createobject("adodb.connection")

conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("fpdb/lianxi1.mdb")

exec="select * from lianxibiao1 where
學號='"&Request.Form("xuehao")&"'"

set rs=server.createobject("adodb.recordset")

rs.open exec,conn,1,3

if (rs.eof and rs.bof) Then

    Response.Write "沒有" & Request.Form("xuehao")

Else

   

    rs("姓名")=Request.Form("xm")           

    rs("學習類型")=Request.Form("xuexilx")           

    rs("學院")=Request.Form("xueyuan")           

    rs("專業")=Request.Form("zhuanye")           

    rs("聯絡電話")=Request.Form("dianhua")           

    rs.update

End If

         rs.close

         set rs=nothing

         conn.close

         set conn=nothing

         

%> 

<%response.write "修改成功!"%>      

 </body>  

然後我們看看結果吧!

點擊提交出現如下介面:

然後可以再框框裡面進行修改了,改後點擊提交就可以了。呵呵!!!修改成功後輸出OK!!

終於結束了!!!祝大家好運!!!

記得分享要註明出處啊。我寫的不容易啊~~~支援下啊~~~~LZM

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.