请教VB+ASP+MTS问题

jackyrong 2001-08-14 11:13:50
用VB+ASP+MTS做了个查询的程序,过程如下,但通不过,不知道
什么原因,敬请指教。
1)查询页面是输入要查询的关键字(keyword),之后用下拉框选择查询条件(kind)比如按书名,按作者,出版社等,之后提交(SEARCH.ASP)
进行查询,查询是分页显示的。
2)用VB做的MTS组件如下,能成功编译并注册到MTS上,
Option Explicit
Private m_keyword1 As Variant
Private m_kind As String
Private m_bookid As Integer
Private m_price As Double
Private m_writer As String
Private m_press As String
Public Property Let keyword1(ByVal vNewValue As Variant)
m_keyword1 = vNewValue
End Property
Public Property Let kind(ByVal vNewValue As Variant)
m_kind = vNewValue
End Property



Public Function ListCourses(bookid As Variant, bookname As Variant, price As Variant, writer As Variant, press As Variant)
On Error GoTo ErrorHandle
Dim strSQL As String
Dim objContext As ObjectContext
Set objContext = GetObjectContext()
' 建立事务性组件
Dim objADOConn As ADODB.Connection
' 利用ADO访问数据库
Dim objrs As ADODB.Recordset
Set objADOConn = New ADODB.Connection
With objADOConn
.ConnectionTimeout = 10
.ConnectionString = "Provider=SQLOLEDB.1;dsn=yi;UserID=sa;Initial Catalog=trade;view=vbook"
' 通过OLEDB建立与数据库的连接
.Open
End With
Set objrs = New ADODB.Recordset
strSQL = "select * from vbook where " & m_kind & " =' %" & m_keyword1 & " %' "
objrs.Open strSQL, objADOConn

' 进行数据库查询

bookid = objrs("bookid")
bookname = objrs("bookname")
writer = objrs("writer")
press = objrs("press")
price = objrs("price")
objrs.MoveNext
'Set ListCourses = objrs
objContext.SetComplte
' 若事务成功完成,则提交该事务
objADOConn.Close
Set objADOConn = Nothing
Set objrs = Nothing
strSQL = ""
'关闭数据库连接,释放所有对象
Exit Function
ErrorHandle:
objContext.SetAbort
Set ListCourses = Nothing
' 若事务失败,则回滚事务
End Function
Public Function iseof() As Boolean

iseof = objrs.EOF
End Function
3)搜索的ASP页面如下(节选有用部分)
<%
keyword=request("keyword")
kind=request("kind")

dim objResult
set objResult=Server.CreateObject("find.search")
objResult.kind=request("kind")
objResult.keyword1=request("keyword")
set rs=Server.CreateObject("ADODB.Recordset")
'dim scores as recordset
dim bookid
dim bookname
dim price
dim writer
dim press
while not objresut.iseof=false
objResult.listcourses bookid,bookname,price,writer,press


<tr>
<td><%=bookid%></td>
<td><%=bookname%></td>
...............
....之后是有关的分页显

但最后程序运行后,明明是数据库有的记录却找不到,但程序没
出错提示,为什么呢?
...全文
110 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jackyrong 2001-08-23
这个问题我自己已经解决了
回复
coolstar 2001-08-23
不是解决了吗,结账吧
回复
jackyrong 2001-08-15
LTPAO的做法改为LIKE后也试不行的。
回复
sugar 2001-08-15
千万不要用全局变量,幸亏你不涉及事务处理
回复
ltpao 2001-08-15
SQL语句不对,如果m_kind 字段为数值
strSQL = "select * from vbook where " & m_kind & " =" & m_keyword1
如果为字符串
strSQL = "select * from vbook where " & m_kind & " Like '%" & m_keyword1 & "%' "
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7521

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2001-08-14 11:13
社区公告
暂无公告