佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1181|回复: 5

请帮忙 SQL search stements complete code

[复制链接]
发表于 25-1-2005 04:11 PM | 显示全部楼层 |阅读模式
Dim strSQL As String


strSQL = "SELECT * FROM Suppliers WHERE Sup_ID Like '%" & (txtSupplierID.Text) & "'"

With adoSuppliers
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Persist Security Info=False; Data Source=" & App.Path & _
"\POS.mdb"
.CommandType = adCmdUnknown
.RecordSource = strSQL
.CursorType = adOpenDynamic
.Mode = adModeReadWrite
.Refresh

If .Recordset.RecordCount > 0 Then
.Recordset.Sort = "Sup_ID"
.Recordset.MoveFirst
optSearch.Visible = True
txtSupplierID.Visible = False
cmdOK.Visible = False
optSearch.Value = Unchecked
End If

Set dtgSuppliers.DataSource = adoSuppliers
With adoSuppliers.Recordset
If .RecordCount > 0 Then

.Find "Sup_ID Like '%" & txtSupplierID.Text & " '"
Else
MsgBox "No such Supplier", vbInformation, "Suppliers"
End If
End With
End With

到底那里有问题???
回复

使用道具 举报


ADVERTISEMENT

发表于 25-1-2005 05:10 PM | 显示全部楼层
POST 你的 strSQL来看看.....CODE是很难CHECK的...
回复

使用道具 举报

发表于 25-1-2005 05:14 PM | 显示全部楼层
问题是什么呢? 错误讯息是什么呢?
回复

使用道具 举报

 楼主| 发表于 27-1-2005 11:46 AM | 显示全部楼层
goatstudio 于 25-1-2005 05:14 PM  说 :
问题是什么呢? 错误讯息是什么呢?


错误讯息是 invalid %xxxxx

VB6+ms acess

goatstudio 和各位大大 可以写个code 给我吗??我的code有问题

strSQL = "SELECT * FROM Suppliers WHERE Sup_ID Like '%" & (txtSupplierID.Text) & "'"

当我click ok 他会 search the data start with  character 我enter 在textbox和 display  在 datagrid or msflexgrid 吗??

我要参考, 谢谢
回复

使用道具 举报

发表于 27-1-2005 01:45 PM | 显示全部楼层
尝试把 % 换成 *

回复

使用道具 举报

发表于 27-1-2005 04:38 PM | 显示全部楼层
Dim strSQL As String


strSQL = "SELECT * FROM Suppliers WHERE Sup_ID LIKE '" & txtSupplierID.Text & "%'" '只是把 “%” 环在后面就可以了。

With adoSuppliers
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Persist Security Info=False; Data Source=" & App.Path & "\POS.mdb"
.CommandType = adCmdUnknown
.RecordSource = strSQL
.CursorType = adOpenDynamic
.Mode = adModeReadWrite
.Refresh


If .Recordset.RecordCount > 0 Then
.Recordset.Sort = "Sup_ID"
.Recordset.MoveFirst
optSearch.Visible = True
txtSupplierID.Visible = False
cmdOK.Visible = False
optSearch.Value = Unchecked
End If

Set dtgSuppliers.DataSource = adoSuppliers
With adoSuppliers.Recordset
If .RecordCount > 0 Then

.Find "Sup_ID Like '" & txtSupplierID.Text & "%'" ‘只是把 “%” 环在后面就可以了。
Else
MsgBox "No such Supplier", vbInformation, "Suppliers"
End If
End With
End With
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 28-11-2024 07:19 AM , Processed in 0.118639 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表