I am very new to VB.net and I am finding it exceptionally difficult to pass an sql query result (string) into a variable.
No matter what I try, I can’t seem to get anything but boolean output from my reader function.
I need to obtain staff “account type” from my staff table and then define that account type in a variable.
Any suggestions?
Thanks.
Here is a good tutorial about using MySQL and VB together:
The piece from this that may be of interest to you:
Note the
MySqlDataReader(reader) object. This lets you get various types of data back. You need to know the column type you are reading, and use the appropriate method.For example if you’re reading a boolean, you would write:
Or a DateTime:
This example uses int arguments to represent the column number, but I find this less intuitive than using the column name. Fortunately
MySqlDataReadersupports column names as well:The example doesn’t show reading these values into variables, but it’s fairly trivial:
(This assumes that your account type column is a string.)
Hopefully this helps get you on the right track.