我得到错误rdr没有声明

时间:2017-10-13 16:30:46

标签: vb.net fingerprint

使用这行代码

using (rdr as mysqldatareader = cmd.executereader()) 

我收到一条错误,说没有声明rdr。当我删除括号使其变为

Using rdr As MySqlDataReader = cmd.ExecuteReader()

我在这行tmpObj.No = rdr("No").ToString()上收到错误,说No不是project.Form.Appdata和this line的成员 tmpObj.Template = templa8和Template不是project.Form.AppData的成员。请注意,我已经在课程级别将Private FPList As New List(Of AppData)作为成员。我肯定做错了什么。有什么建议吗?

'THIS NEEDS TO BE AT THE CLASS-LEVEL, AS A MEMBER
'Private FPList As New List(Of AppData)
     Public Class AppData

     Public Sub Update()
        RaiseEvent OnChange()
    End Sub
    Public Event OnChange()
    Public FPList As New List(Of AppData)
    Public IsEventHandlerSucceeds As Boolean = True
    Public IsFeatureSetMatched As Boolean = False
    Public FalseAcceptRate As Integer = 0
    Public Sub Update()
        RaiseEvent OnChange()
    End Sub
    Public Event OnChange()
    Public FPList As New List(Of AppData)
    End Class



Private Sub Me_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles MyBase.Load
    Init()
    StartCapture()
    Dim sql As String = "SELECT * FROM new_case_file"    
    Using conn As New MySqlConnection("**** "), _
       cmd As New MySqlCommand(sql, conn)

        conn.Open()
        Using (rdr As MySqlDataReader = cmd.ExecuteReader())
           FPList.Clear()
            While (rdr.Read())
                Dim tmpObj As New AppData
                tmpObj.No = rdr("No").ToString()

                Dim fpBytes As Byte() = rdr("FingerPrint")
                Using MemStream As New IO.MemoryStream(fpBytes)

                    Dim templa8 As New DPFP.Template()
                    templa8.DeSerialize(MemStream)
                    tmpObj.Template = templa8
                End Using

                FPList.Add(tmpObj)
            End While
            rdr.Close()
        End Using
    End Using 
End Sub

1 个答案:

答案 0 :(得分:0)

通过将以下内容添加到AppData类

来更正该错误
Private _No As String
Public Property No As String
    Get
        Return _No
    End Get
    Set(value as String)
        _No = value
    End Set
End Property

Private _Template As DPFP.Template
Public Property Template As DPFP.Template
    Get
        Return _Template
    End Get
    Set(value as DPFP.Template)
        _Template = value
    End Set
End Property

但这并不一定会使您的代码有效。