Salve a tutti.
Ho dichiarato un metodo in una mia classe che si occupa di gestire un Reader ( mysqldatareader )
Il metodo della classe è il seguente
e il modo in cui lo richiamo è questo quicodice:Public Sub Lettore(ByRef Lettore As MySqlDataReader, ByVal StringaSQL As String) ConnessioneSQL("localhost", "root", "**", "**") Try _CMD.CommandText = StringaSQL _CMD.Connection = _Connessione Lettore = _CMD.ExecuteReader Catch ex As Exception Lettore = Nothing End Try End Sub
Come mai mi da una null reference quicodice:If Form1.ModificaAttiva = True Then Dim SQLString As String SQLString = "SELECT Nome, Cognome, Telefono FROM tabella WHERE IDCliente = '" & Form1.RowIndex & "'" Dim ManagerSQL As New clsSQL Dim Lettore As MySqlDataReader ManagerSQL.Lettore(Lettore, SQLString) While Lettore.Read() TXTnome.Text = Lettore.GetString(0) End While Lettore.Close() FRMElencoClienti.ModificaAttiva = False End If
Dicendomi che devo stanziare l'oggetto ?codice:While Lettore.Read()
Grazie a tutti.
Buona Giornata

Rispondi quotando