查看: 1181|回复: 5
|
请帮忙 SQL search stements complete code
[复制链接]
|
|
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
到底那里有问题??? |
|
|
|
|
|
|
|
发表于 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 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|