---
title: "RecordCount=-1问题"
author: "afeix"
date: "2013-04-25T09:23:57Z"
tags: []
categories: ["互联网"]
slug: "recordcount-1"
draft: false
lastmod: "2013-04-25T09:23:57Z"
id: 1853258
url: "https://afeix.iteye.com/blog/1853258"
---

通常人们使用以下两种方法来执行SQL语句：

Set Rs=Conn.Execute(SqlStr)

和

Set Rs=Server.CreateObject(“ADODB.RecordSet“)

Rs.Open SqlStr,Conn,CursorType,LockType

（RecordSet对象方法请看这里）

由于默认的记录集游标是服务器游标，

Rs.CursorLocation = adUseServer

所以返回Rs.RecordCount=-1,

应该把服务器游标改为客户端游标，

Rs.CursorLocation = adUseClient

Rs.Open SqlStr,Conn,CursorType,LockType

rs.cursortype

光标类型 recordcount 属性