World Of Webmaster
Đăng nhập / Đăng ký
Account
Free for web
Check pagerank
Input check pager (Not http://)

Ext: blog.kai.vn
Check google pagerank
View HTML source
FUNCTION LIBRARY
HTML Tags Library
PHP Functions Library ASP Functions Library
ASP Functions RecordCount2
Chức năng: Đếm số bản ghi có trong một table của DB
Ngôn ngữ: asp - Nhóm: database
CÚ PHÁP
  long = RecordCount2(connstring, tableName) 

Hàm RecordCount2 đếm số lượng bản ghi trong bảng và trả về ở dạng long.
Sử dụng được với các DB: , MSSQL và MySQL.
Các đối số:
constring: Đường dẫn đến DB tồn tại.
tableName: Tên bảng trong DB.

VÍ DỤ
<%
  '--- Use RecordCount to determine the record  count returned from a given Table Name. 
  
  Dim a, cn
    cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data  Source=" & Server.Mappath("/database/mydata.mdb") & ";"
      a = RecordCount2(cn, "YourTableName")
  Response.Write a & " Records Found!"
%> 
ASP Code
<%
  Private Function RecordCount2(byVal connstring, byVal TableName)
      '--- MSAccess, MSSQL  and MySQL
      Dim objCn, bErr1, bErr2, strErrDesc, objRs, strSQL
      On Error Resume Next
          Set objCn = Server.CreateObject("ADODB.Connection")
          objCn.Open ConnString
              If Err Then 
                  bErr1 = True
              Else
                  strSQL = "SELECT COUNT(*) AS Record_Count FROM " & TableName
                  Set objRs = objCn.Execute(strSQL)
                  RecordCount2 = CLng(objRs("Record_Count"))
                  objRs.Close
                  Set objRs = Nothing
                  If Err Then 
                      bErr2 = True
                      strErrDesc = Err.Description
                  End If
              End If
          objCn.Close
          Set objCn = Nothing
      On Error GoTo 0
      If bErr1 then
          Err.Raise 5109, "RecordCount2  Function", "Bad connection string. Database cannot be  accessed."
          RecordCount2 = Null
      ElseIf bErr2 then
          Err.Raise 5109, "RecordCount2  Function", strErrDesc
          RecordCount2 = Null
      End If
  End Function '--- RecordCount2
%> 

CompactDB
DateDB
EscapeApos
EscapeBit
EscapeDate
EscapeInt
MkDatabase
NoSQLInjection
Procedures
RecordCount
Library ›› HTML Tag | PHP Function | ASP Function
Page : 806841
Online :
Visited : 370164
 
Liên h | Thêm vào Favorite | Gửi link qua e-mail | Thông tin website
Copright © 2009 KAI Blog
Code by BOINGOnline. Contact email : contact@kai.vn
Theme: default | classic |