ASP and Access databases

Source: Internet
Author: User
Tags include mail table name trim
access| Data | Database |access 1 You can customize a table to pull data from the database:
<% set Rs=server. CreateObject ("Adodb.recordset")
Rs. Open "SELECT * from AD ORDER by BS", conn,1,1
Do but not Rs. Eof
Response. Write "<a href=" &trim (rs ("url")) & "Target=_blank>" &trim (RS ("Wordlink")) & "</a><br" > "
Rs. MoveNext
Loop
Rs. Close
Set rs=nothing
%>
Note: "Wordlink" is a field name inside the table.
2 connection databases generally use this statement:
<!--#include file= "conn.asp"-->
The conn.asp code is as follows:
<%@ CODEPAGE = "936"%>//This sentence can not be
<%
Dim conn
Dim connstr
Dim db
db= "Db/my.mdb"
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB)
Conn. Open ConnStr
Startime=timer ()
%>
3 For example: The following is the page to add a message: (the second file name is tianjia.asp)
<!--#include file= "conn.asp"-->
<%
Set Rs=server.createobject ("Adodb.recordset")
Name = Request ("name")
Mail = Request ("email")
face = Request ("Face")
Sql= "SELECT * from Message" (The message is a table name)
Rs.Open sql,conn,3,3
Rs.addnew
RS ("A_name") =name
RS ("A_mail") =mail
RS ("Face") =face//This is the selected image, in the database table field can be used Image/1.jpg
Rs.update
Rs.close
Response.Redirect "xianshi.asp"//This is the redirect page, which jumps to the xianshi.asp
%>
<%
Set rs=nothing
Conn.close
Set conn=nothing
%>
In writing the message page, just add this statement: <form action=tianjia.asp method=post> will be called when submitting tianjia.asp
4 <%
Set Rs=server.createobject ("Adodb.recordset")//to operate on a table this statement is OK.
SQLcmd = "SELECT * from" A_time Desc "//chronological order (A_time) is a field
Rs. Open SQLcmd, Conn, adOpenStatic, adlockpessimistic
page = CLng (Request ("Txtpage")
Rs. PageSize = 5//per page display five message
If Page < 1 Then page = 1
If page > RS. PageCount Then page = RS. PageCount//Total pages
Rs. AbsolutePage = page
%>
This statement is only required when you want to display the total number of pages: <%=rs. Pagecount%>
To display the current page as a few pages, just this statement: <%=page%>
Here is how to perform the previous page, next page display method
<%
If page <> 1 Then
Response.Write "<td ><font size=4>" &_
"<a href=xianshi.asp?txtpage=1> Home </a>"
Response.Write "<td ><font size=4>" &_
"<a href=xianshi.asp?txtpage=" & (page-1) & "> previous page </a>"
End If
If page <> RS. PageCount Then
Response.Write "<td ><font size=4>" &_
"<a href=xianshi.asp?txtpage=" & (Page + 1) & "> next page </a>"
Response.Write "<td ><font size=4>" &_
"<a href=xianshi.asp?txtpage=" & RS. PageCount & "> End </a>"
End If%>
From Guangdong
Image
|
|
|
|
| image
Name <font> from <%=rs ("area")%> </font> the word "Guangdong" can be paged out from the database
"width=" height= "", border=0> to pull out the picture
The following 123 is also <%=rs from the database ("A_name")%>
To drop something, just move the cursor to where and then "fetch" the &n.



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.