There are a number of problems here: first off never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
Second, never use
SELECT * FROM
- always specify exactly which columns you want to retrieve, and the order in which you want them. That way, you don't transfer data you don't need - which saves bandwidth - and your code becomes more immune to changes on the database causing it to crash because the column order is different, or worse corrupt data. This is particularly important if you use numeric indexes to retrieve column content instead of string based column names.
Thirdly, don't use a DataTable to retrieve a single user details - use a DataReader instead, it's a lot more memory efficient - and check the return to make sure there is data before you try to access it! If there is no user with that name, your code crashes and burns...
Fourthly, do not use the code in Solution 1: the documentation for
Image.FromStream Method (Stream) (System.Drawing)[
^] is very specific that the stream must remain open for the life of the image, which the using block does not allow.
Dim ms As New MemoryStream(bytes)
Dim useThisImage As Image = Image.FromStream(ms)