ASP operation Access database read-write delete __ Database

Source: Internet
Author: User

Open Database

<%
' On Error Resume Next
Set conn = Server.CreateObject ("ADODB. Connection ")
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("Data/db.mdb")
Conn.Open ConnStr
% >

Close Database

<%
Conn.close
Set conn = Nothing
% >

Repair Gamma I database information

<%
' Insert
sql = "INSERT into Branchtype (BRANCHNAME,SJ) VALUES ('" & Branchname & ", '" & Now () & "")
Conn.execute (SQL)

' Modify
sql = "Update branchtype set Branchname= '" & Branchname & "where branchid=" & CLng (Branchid)
Conn.execute (SQL)

' Delete
sql = "Delete * from Newslist where id=" & ID
Conn.execute (SQL)

Read database information and display

' No paging display
sql = "Select Branchname from Branchtype where branchid=" & Branchid
Set rs = conn.execute (SQL)
If not rs.eof then
Do as not rs.eof
Response.Write rs ("Branchname") & "<br/>"
Rs.movenext
Loop
Else
Response.Write "Sorry, no data"
End If
Set rs = Nothing


' Pagination display
Set rs = Server.CreateObject ("Adodb.recordset")
Rs.Open Sql,conn, 1, 1
If not rs.eof then
Rs. PageSize = 16 ' Number of data bars displayed per page
page = Request ("page")
If IsNumeric (page) = False Then
page = 1
ElseIf page = "" Then
page = 1
End If
page = CLng (page)
If page > Rs.pagecount then
page = Rs.pagecount
End If
Rs. AbsolutePage = page
For i = 1 to Rs.pagesize
If rs.eof or Rs.bof then
Exit For
End If
Response.Write rs ("Branchname") & "<br/>"

Rs.movenext
Next
If Rs.pagecount > 1 Then
% >
<% if page <> 1 then% > < a href =<% = webpage% > page = 1 title = home > Home </a &GT;&L T % Else% >< Font color = DCDCDC > Home </font > <% End If% >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.