请大家帮我看看为什么我用这条sql语句查询不到access数据库的数据表中的一条记录?

Dim policeman As Integer
Dim Kuvasz As String
policeman = InputBox("请输入查询编号!", "输入编号进行查询", 1)
Kuvasz = "SELECT 编号 from Temresult where 编号=" & policeman
Call OpenAdoRecordset(Kuvasz, vsoReco)
enquiry.Label21.Caption = policeman
enquiry.Label3.Caption = vsoReco.Fields("台区名称").Value
enquiry.Label5.Caption = vsoReco.Fields("总供电量").Value
其中openAdoRecordset是:
Public Sub OpenAdoRecordset(ByVal strSQL As String, vsoReco As ADODB.Recordset)
Dim vsoConn As ADODB.Connection
Dim strcnn As String
Set vsoConn = New ADODB.Connection
Set vsoReco = New ADODB.Recordset
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\WW\data.mdb"
vsoConn.Open strcnn
Set vsoReco.ActiveConnection = vsoConn
vsoReco.CursorType = adOpenStatic
vsoReco.LockType = adLockOptimistic
vsoReco.Open strSQL
End Sub
数据表Temresult的编号字段是整型,按编号查询到一条指定的记录。

Kuvasz = "SELECT 编号 from Temresult where 编号=" & policeman
enquiry.Label3.Caption = vsoReco.Fields("台区名称").Value
enquiry.Label5.Caption = vsoReco.Fields("总供电量").Value
--------------------------------
更改为
Kuvasz = "SELECT 台区名称字段名, 总供电量字段名 from Temresult where 编号=" & policeman
enquiry.Label3.Caption = vsoReco.Fields(0).Value
enquiry.Label5.Caption = vsoReco.Fields(1).Value
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答