Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When l run this code l get the error

(rdr As MySqlDataReader = cmd.ExecuteReader()) rdr is not declared, it may be inaccessible due to its protection level. Please help!

What I have tried:

Private FPList As New List(Of AppData)

Private Sub Me_Load(ByVal sender As System.Object, ByVal e AsSystem.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
Posted
Updated 13-Oct-17 6:08am

Remove the brackets:
VB
Using (rdr As MySqlDataReader = cmd.ExecuteReader())

Becomes
VB
Using rdr As MySqlDataReader = cmd.ExecuteReader()
 
Share this answer
 
Comments
Jim Adjei-Wiredu 13-Oct-17 12:19pm    
Thanks for the reply, when l remove the brackets, I get error on this line tmpObj.No = rdr("No").ToString() and this line
tmpObj.Template = templa8. Note that l have already put this: Private FPList As New List(Of AppData) at the class level, as a member. Definitely l'm doing something wrong. Any suggestions?
OriginalGriff 13-Oct-17 12:23pm    
What errors - if you read them, they are normally pretty self explanatory. But without knowing what the error messages are, we can't tell what the problem might be.
Jim Adjei-Wiredu 13-Oct-17 12:39pm    
When the brackets are on as in Using (rdr As MySqlDataReader = cmd.ExecuteReader()),
I get the error rdr "is not declared, it may be inaccessible due to its protection level and also As gives the error ')' is expected. When l remove the brackets as you suggested, I get error on error on this line tmpObj.No = rdr("No").ToString() 'No' is not a member of the project.Form.AppData, also tmpObj.Template = templa8 gives an error 'Template is not a member of the project.Form.AppData. I'm new to VB.Net and programming in general. Would appreciate any help. Thanks.
OriginalGriff 13-Oct-17 14:00pm    
Then look at the error message!
"'No' is not a member of the project.Form.AppData"
Looking at your class definition in your comment to Richard there is not member called "No". No member, no access - You get an error.
We can't fix that for you, we have no idea what you meant it to be...
Equally, there is not "Template" - there is a "Templates" did you mean that?
Remove the outer parenthesis fron the statement, thus:
VB
Using rdr As MySqlDataReader = cmd.ExecuteReader()

See also Using Statement (Visual Basic) | Microsoft Docs[^].
 
Share this answer
 
Comments
Jim Adjei-Wiredu 13-Oct-17 12:19pm    
Thanks for the reply, when l remove the brackets, I get error on this line tmpObj.No = rdr("No").ToString() and this line
tmpObj.Template = templa8. Note that l have already put this: Private FPList As New List(Of AppData) at the class level, as a member. Definitely l'm doing something wrong. Any suggestions?
Richard MacCutchan 13-Oct-17 12:47pm    
What errors, and what is the definition of AppData?
Jim Adjei-Wiredu 13-Oct-17 13:00pm    
It's a class I built
Public Class AppData

Public Const MaxFingers As Integer = 10
' members
Public EnrolledFingersMask As Integer = 0
Public MaxEnrollFingerCount As Integer = MaxFingers
Public IsEventHandlerSucceeds As Boolean = True
Public IsFeatureSetMatched As Boolean = False
Public FalseAcceptRate As Integer = 0
Public Templates(MaxFingers - 1) As DPFP.Template
'Dim FPList As List(Of AppData) = New List(Of AppData)

Public Sub Update()
RaiseEvent OnChange()
End Sub
Public Event OnChange()
Public FPList As New List(Of AppData)

End Class

I got this from my research online.
Richard MacCutchan 14-Oct-17 4:29am    
That class does not contain either field No or Template.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900