Recommended: ASP uses Google to implement online translation function Sometimes I want to provide multi-language support for our web pages. It is too troublesome to use one web page for one language. Fortunately, Google provides language tool functions. The following describes how to use it to convert web pages between multiple languages. . lan.htm
Define conn.asp first
| <% dim objConn dim strConn strConn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & chr(34) & Server.MapPath(data.mdb) & chr(34) set objConn = server.createobject(adodb.connection) objConn.open strConn %> |
Let's take a look at several different ways to open record sets
Method 1.
| dim sql dim objRs sql = select * from table1 set objRs = objConn.execute( sql ) |
This method uses SQL to return and obtains the record set, which is relatively simple to obtain the filtered record set, but the record set obtained in this way cannot be displayed paging.
File text1.asp
<%@LANGUAGE=VBSCRIPT CODEPAGE=936%> <!-- #include file=conn.asp --> <% dim sql dim objRs sql = select * from table1 set objRs = objConn.execute( sql ) objRs.pagesize = 5 objRs.absolutepage = 1 %> |
The result of requesting this page is:
-------------------------------------------------- ----------
Error Type:
ADODB.Recordset (0x800A0CB3)
Bookmarks are not supported in the current record set. This may be a limitation of the provider or selected cursor type.
/msg/test1.asp, line 12
Browser type: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Web page: GET /msg/test1.asp
Time: September 21, 2007, 19:58:01
-------------------------------------------------- ----------
Method 2.
| dim objRs set objRs = Server.CreateObject( ADODB.Recordset ) objRs.open table1 , objConn , 1 , 2 |
Records opened in this way can be displayed paging.
| <% dim objRs set objRs = Server.CreateObject( ADODB.Recordset ) objRs.open table1 , objConn , 1 , 2 objRs.pagesize = 5 objRs.absolutepage = 1 %> |
Try this, haha, run smoothly.
However, the recordsets opened in this way cannot be sorted
File test2.asp
| <%@LANGUAGE=VBSCRIPT CODEPAGE=936%> <!-- #include file=conn.asp --> <% dim objRs set objRs = Server.CreateObject( ADODB.Recordset ) objRs.open table1 , objConn , 1 , 2 objRs.sort = field1 %> |
The result of requesting this page is:
-------------------------------------------------- ----------
Error type: ADODB.Recordset (0x800A0CB3)
The current provider does not support the interface required for sorting or filtering.
/msg/test2.asp, line 17
Browser type: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Web page: GET /msg/test2.asp
Time: September 21, 2007, 20:17:32
-------------------------------------------------- ----------
What to do?
Ha, that's all.
| <%@LANGUAGE=VBSCRIPT CODEPAGE=936%> <!-- #include file=conn.asp --> <% dim objRs set objRs = Server.CreateObject( ADODB.Recordset ) objRs.CursorLocation = 3 objRs.open table1 , objConn , 1 , 2 objRs.sort = field1 desc %> |
To summarize:
1. Method 1: You can easily filter the records you want through SQL statements.
2. Method 2, the function is relatively powerful, but more complex.
There are more useful uses in this method. See other reference materials for details.
Share: Implement room functions and user display in the asp chat room After I wrote the article "Implementing the Whispering Function in the Asp Chat Room", many friends wrote to me to ask me questions about the implementation of other advanced functions. Indeed, advanced functions such as room and user management are essential functions for a complete chat room. Here, the room work