I'm trying to get a single row by executing a SELECT statement with a primary key
I have tried to assign the output of command.ExecuteScalar()
to an Object
variable then tried accessing the values by key like obj('column_name')
Using conn As New SQLiteConnection(connectionString:=connection.get_connection_string())
conn.Open()
Dim sql_string As String = "SELECT * FROM employees WHERE id = @id"
Using cmd As New SQLiteCommand(connection:=conn, commandText:=sql_string)
cmd.Parameters.AddWithValue("@id", employee_id)
Dim reader As Object = cmd.ExecuteScalar()
If reader <> Nothing Then
Me.user_details(2) = reader("first_name")
End If
End Using
End Using
I was expecting to reap the values in the column first_name
from reader('first_name')
but i'm getting a NullReferenceException
exception