gpt4 book ai didi

sql - 为什么这个 VB 和 SQL 不起作用?

转载 作者:搜寻专家 更新时间:2023-10-30 22:01:21 25 4
gpt4 key购买 nike

Private Sub Text46_AfterUpdate()

Dim strSource2 As String

strSource2 = "SELECT [Product Code],[Stock Level],[Description] FROM [products/stock] WHERE [Product Code] LIKE " & "'%" & Me.Text46.Value & "%';"

Me.listSource.RowSource = strSource2
Me.listSource = vbNullString

End Sub

它应该以某种方式在数据库中搜索产品代码与 Text46 的值匹配的所有产品,但我真的无法让它工作,我真的不知道为什么。 listSource 是我希望信息出现在其中的列表框。

提前致谢,鲍勃P

最佳答案

在 MS Access 中,通配符是 * 而不是 %,除非您正在使用 ADO,或者您已经在选项中更改了 ANSI 标准。

"SELECT [Product Code],[Stock Level],[Description] " _
& "FROM [products/stock] " _
& "WHERE [Product Code] LIKE " & "'*" & Me.Text46.Value & "*';"

关于sql - 为什么这个 VB 和 SQL 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12621326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com