怎样在VB中声明SQL 变量?急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/09/23 07:26:43
Private Sub Command1_Click()
Dim che As String
che = Str(InputBox("请输入列车车次:", "输入框", 0))
Adodc1.RecordSource = "select * from trai where checi like ?"
Adodc1.Refresh WHERE后面应该怎么写?要求比较CHE相同的值CHECI是数据表中的列值,是要声明SQL变量吗?

建议最好用 & 符号:
Adodc1.RecordSource = "select * from trai where checi =" & che

若用 Like 须这样写:
Adodc1.RecordSource = "select * from trai where checi like '%" & che & "%'"

Private Sub Command1_Click()
Dim che As String
che = Str(InputBox("请输入列车车次:", "输入框", 0))
Adodc1.RecordSource = "select * from trai where checi = " + che
Adodc1.Refresh
这样改就行了~