数据库查询内存溢出!!!!

dong127 2005-03-28 10:53:16
对access数据库中的字段(存放日文字符)进行查询

例如: select * from T_Convert T_StrJP like "%f%"

在vb界面能正常运行,但是编译后运行会报错"内存溢出","ERR=-2147217900,Automation错误"

发现只要SQL语句中包含此字段的条件查询就会如此....

但是如果select * from T_Convert T_StrJP like "%" 却是好的(能把全部记录找出来).....

想不明白啊.....

哪位达人帮帮忙啊!!~~~~~~
...全文
224 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljhdi 2005-03-29
  • 打赏
  • 举报
回复
晕,还有这种事,学习一下
dong127 2005-03-28
  • 打赏
  • 举报
回复
to tztz520(午夜逛街):

第一,数据库里的字段会包含单引号..

第二,单引号也报错啊

to ljhdi():

Private Sub cmdSearch_Click()
On Error GoTo err_cmdSearch_Click
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & _
".\DB\String.mdb;Persist Security Info=False"
'声明ADO变量
Dim strSelect As String '用于存放SQL句子
Dim strWhere As String '用于存放SQL句子
'生成SQL句子
strSelect = "select * from T_Convert "
strWhere = " where (1=1) "
If Trim(Me.txtStrJP.Text) <> "" Then
strWhere = strWhere & " and T_StrJP like " & Chr(34) & "%" & Trim(Me.txtStrJP.Text) & "%" & Chr(34) & " "
End If
If Trim(Me.txtStrCN.Text) <> "" Then
strWhere = strWhere & " and T_StrCN like " & Chr(34) & "%" & Trim(Me.txtStrCN.Text) & "%" & Chr(34) & " "
End If
If Trim(Me.txtFileList.Text) <> "" Then
strWhere = strWhere & " and T_FileList like " & Chr(34) & "%" & Trim(Me.txtFileList.Text) & "%" & Chr(34) & " "
End If
If Me.chkCommand.Value = 1 And Me.chkAll.Value = 0 Then
strWhere = strWhere & " and T_Command=1 "
End If
If Me.chkMsgbox.Value = 1 And Me.chkAll.Value = 0 Then
strWhere = strWhere & " and T_Msgbox=1 "
End If
If Me.chkNormal.Value = 1 And Me.chkAll.Value = 0 Then
strWhere = strWhere & " and T_Normal=1 "
End If
'如果没有输入检索条件,则询问是否要检索
If Trim(strWhere) = "where (1=1)" Then
PintTEMP = MsgBox("因为没有输入任何检索条件,所以得到的记录数可能会很大,是否要继续?", vbQuestion + vbYesNo, PCTitleQuestion)
If PintTEMP = vbNo Then GoTo ext_cmdSearch_Click
End If
'打开ADO记录集
Adodc1.RecordSource = strSelect & strWhere
Adodc1.Refresh
'把记录集里面的数据表示在表格控件里面
Me.fpdResult.MaxRows = 0
If Adodc1.Recordset.RecordCount = 0 Then
Me.txtStrJP.SetFocus
GoTo ext_cmdSearch_Click
Else
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
With Me.fpdResult
.MaxRows = .MaxRows + 1
.Row = .MaxRows
.Col = 1 '日文字符串
.Text = IIf(IsNull(Adodc1.Recordset.Fields("T_StrJP")), "", Trim(Adodc1.Recordset.Fields("T_StrJP"))) & " "
.Col = 2 '中文字符串
.Text = IIf(IsNull(Adodc1.Recordset.Fields("T_StrCN")), "", Trim(Adodc1.Recordset.Fields("T_StrCN"))) & " "
.Col = 3 '文件列表
.Text = IIf(IsNull(Adodc1.Recordset.Fields("T_FileList")), "", Trim(Adodc1.Recordset.Fields("T_FileList"))) & " "
.Col = 4 'GUID号
.Text = Trim(Adodc1.Recordset.Fields("T_GUID"))
End With
Adodc1.Recordset.MoveNext
Loop
Me.fpdResult.SetFocus
End If

ext_cmdSearch_Click:
Exit Sub
err_cmdSearch_Click:
Select Case Err.Number
Case Else
PintTEMP = MsgBox("Err = " & Err.Number & " " & vbLf & Err.Description, vbCritical + vbRetryCancel, PCTitleError)
Select Case PintTEMP
Case vbCancel 'Cancel
GoTo ext_cmdSearch_Click
Case vbRetry 'Retry
Resume
End Select
End Select
End Sub
tztz520 2005-03-28
  • 打赏
  • 举报
回复
这样呢
select * from T_Convert Where T_StrJP like '%f%'
ljhdi 2005-03-28
  • 打赏
  • 举报
回复
这个好像没有错呀

最好贴源代码出来,方便找错误
dong127 2005-03-28
  • 打赏
  • 举报
回复
啊,不好意思.贴错了

应该是这个:select * from T_Convert Where T_StrJP like "%f%"

select * from T_Convert Where T_StrJP like "%"
ljhdi 2005-03-28
  • 打赏
  • 举报
回复
where 都没有?
dong127 2005-03-28
  • 打赏
  • 举报
回复
已经找到了问题的所在,谢谢大家帮忙..

http://www.blueidea.com/bbs/NewsDetail.asp?id=1768538

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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