俺有一个程序,原来采用Access 97, 运行得很好,将其升级到Access 2000后。
出现问题,出现问题的模块为以下模块'查询邮编及其它
Private Function QueryZip(ZipStr As String, ResultRecord As ADODB.Recordset) As Boolean
Dim SQLStr As String
Dim comZip As ADODB.Command
Dim tempStr As String
If Len(Trim(ZipStr)) = 0 Then
QueryZip = False
Else
tempStr = "'%" & Trim(ZipStr) & "%'" '转成 *湘潭*这样的查询字符串
SQLStr = "SELECT short,province,city,zone,post " _
& " FROM Zip" _
& " WHERE ( short LIKE " & tempStr & ") OR (" _
& " province LIKE " & tempStr & ") OR (" _
& " city LIKE " & tempStr & ") OR (" _
& " zone LIKE " & tempStr & ") OR (" _
& " post LIKE " & tempStr & ")"
Set comZip = New ADODB.Command
With comZip
.ActiveConnection = glbSD.gQueryDB.cnnDB
.CommandText = SQLStr
End With
Set rstZip = New ADODB.Recordset
'
'以下为出现问题的语句
'提示 Open的 _RecordSet 方法出错。
'
rstZip.Open comZip, , adOpenKeyset, adLockOptimistic, adCmdText
Set comZip = Nothing
Set ResultRecord = rstZip
QueryZip = True
End If
End Function1、我已经将数据库转成Access 2000的版本
2、strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;" 而且很奇怪的问题是,在一个数据库中有多张表,而只有一个表的查询出错。
请问大家有没有碰到过这种情况,是如何解决的?
出现问题,出现问题的模块为以下模块'查询邮编及其它
Private Function QueryZip(ZipStr As String, ResultRecord As ADODB.Recordset) As Boolean
Dim SQLStr As String
Dim comZip As ADODB.Command
Dim tempStr As String
If Len(Trim(ZipStr)) = 0 Then
QueryZip = False
Else
tempStr = "'%" & Trim(ZipStr) & "%'" '转成 *湘潭*这样的查询字符串
SQLStr = "SELECT short,province,city,zone,post " _
& " FROM Zip" _
& " WHERE ( short LIKE " & tempStr & ") OR (" _
& " province LIKE " & tempStr & ") OR (" _
& " city LIKE " & tempStr & ") OR (" _
& " zone LIKE " & tempStr & ") OR (" _
& " post LIKE " & tempStr & ")"
Set comZip = New ADODB.Command
With comZip
.ActiveConnection = glbSD.gQueryDB.cnnDB
.CommandText = SQLStr
End With
Set rstZip = New ADODB.Recordset
'
'以下为出现问题的语句
'提示 Open的 _RecordSet 方法出错。
'
rstZip.Open comZip, , adOpenKeyset, adLockOptimistic, adCmdText
Set comZip = Nothing
Set ResultRecord = rstZip
QueryZip = True
End If
End Function1、我已经将数据库转成Access 2000的版本
2、strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;" 而且很奇怪的问题是,在一个数据库中有多张表,而只有一个表的查询出错。
请问大家有没有碰到过这种情况,是如何解决的?
解决方案 »
- 关于line方法画方框的问题
- 关于tabstrip的问题
- 请问各位高手作报表有什么好的解决方案?
- 今天发了奖金,发分,只限前10名……
- 请教一个VB程序打开自定义文件的问题?
- VB有函数直接算出一个字符在一字段里共出现有几次吗??
- 用InputBox取得用户的输入,我该怎样区别:如果用户什么也没输按“确认” 与按“取消”健,即刻结分,在线守候
- 如何通过API在注册表里修改打印机的PORTNAME。
- vb+TTS开发简易语音识别程序
- **************水晶报表怎么连接dao数据源******
- Set语句什么时候用,怎么区分?
- 为什么我的VB程序在我的机子上运行的很好,在别人的机子上运行时有以下的问题
SQLStr = "SELECT short,province,city,zone,post " _
& " FROM Zip" _
& " WHERE ( short LIKE " & tempStr & ") OR (" _
& " province LIKE " & tempStr & ") OR (" _
& " city LIKE " & tempStr & ") OR (" _
& " zone LIKE " & tempStr & ") OR (" _
& " post LIKE " & tempStr & ")"
大家看我这句有没有出错,问题是我在ACCESS97也没有一点问题!