和书上打得一模一样,可是居然出现该对象不支持该操作的错误(书配盘的源码可通过)

smileme 2002-02-19 10:32:11
和书上打得一模一样,可是居然出现该对象不支持该操作的错误(书配盘的源码可
通过)
Option Explicit
Private Const BIBLIO_PATH = "C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb"
Private Sub Form_Load()
Dim dbfBiblio As Database, recSelect As Recordset
Dim strSQL As String, strSubQuery As String
Dim intCount As Integer, intGridRow As Integer
'get the database name and open the database
Set dbfBiblio = DBEngine.Workspaces(0).OpenConnection(BIBLIO_PATH)
'build the subquery ,starting with its SELECT statement
strSubQuery = "SELECT City FROM Publishers as Tmp " & _
"GROUP BY City,State " & _
"HAVING COUNT(*)>1 AND State=Publishers.State"
'build the SQL statement
'start by designating the fields to be included in the recordset
'and the WHERE IN clause
strSQL = "SELECT City,State,[Company Name] FROM Publishers " & _
"WHERE City IN (" & strSubQuery & ") " & _
"ORDER BY State,City"
'run the query
Set recSelect = dbfBiblio.OpenRecordset(strSQL, dbOpenSnapshot)
'make sure the query returned at least one record
If recSelect.RecordCount > 0 Then
'get a count of records in the recordset and display it on the form
recSelect.MoveLast
intCount = recSelect.RecordCount
lblcount.Caption = intCount

'initialize the grid
With grdValues
.Rows = intCount + 1
.ColWidth(0) = 700: .ColWidth(1) = 2000: .ColWidth(2) = 4000

.Row = 0: .Col = 0: .Text = "State"
.Col = 1: .Text = "City"
.Col = 2: .Text = "Publisher"
End With
'populate the grid
recSelect.MoveFirst
For intGridRow = 1 To intCount
With grdValues
.Row = intGridRow
.Col = 0: .Text = recSelect![State]
.Col = 1: .Text = recSelect![City]
.Col = 2: .Text = recSelect![Company Name]
End With
recSelect.MoveNext
Next intGridRow
End If
End Sub
...全文
67 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangsiyuan 2002-02-19
  • 打赏
  • 举报
回复
do you set Data Enviroment?
my_wei 2002-02-19
  • 打赏
  • 举报
回复
你漏掉引用dll的方法了,看书上代码中引用了什么,你在你程序里引用就可以了
limit 2002-02-19
  • 打赏
  • 举报
回复
看看书上的代码引用了什么ocx和dll,你也跟着引用就行了。
40Star 2002-02-19
  • 打赏
  • 举报
回复
对,你必须引用否则用不了
dbcontrols 2002-02-19
  • 打赏
  • 举报
回复
工程--引用--Microsoft DAO 3.51 Object Library
bestluo 2002-02-19
  • 打赏
  • 举报
回复
你把他的原码paste到你的代码区试一下

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧