So I am fairly new (read just starting) to PostgreSQL and VB.net. I have done research and am using the Npgsql.dll and Mono.Security.Protocol.Tls.dll as references to connect to the database.
|barcode|item|type|received|removed|on_hand|
|ien0001|thing1|type1| 1 | 2 | 3 |
|ien0002|thing2|type2| 4 | 5 | 6 |
|ien0003|thing1|type1| 7 | 8 | 9 |
Example of my table
Now the issue that I am having is that when I use myReader.GetString(0) the value being returned is always 0. Now if I hardcode this line to this below I will get the actual value that is in the database. I'm not sure if I am doing something stupid or if I am in over my head. Any advice would be great. I hope the question is clear. If not please let me know and I will try to rephrase. Also this is my first time posting so let me know if my formatting is awful.
Thanks
Also if I don't hardcode the barcode then (no pun intended) then the if statement is never executed.
Also I forgot to mention what I am trying to accomplish. I am trying to query the database using a VB variable called code. Then based on the results of the query (there will only be at most one result) extract a value from a column and save that to another variable.
If there is another way of doing this please let me know. Thanks
mySQLString = "SELECT On_Hand FROM total_inventory WHERE Barcode = 'ien0002' ;"
code = "'ien0001'" 'code is a string
myConnection.ConnectionString = "Server=###.###.###.###;Port=####;Database=inventory;User Id=inventory_user;Password=$$$$$$;"
myConnection.Open()
myCommand = New NpgsqlCommand(mySQLString, myConnection)
myCommand.ExecuteNonQuery()
myReader = myCommand.ExecuteReader
If myReader.Read() Then
CurrentQty = CInt(myReader.GetString(0))
MsgBox(":" & CurrentQty)
End If
myReader.Close()
MsgBox(CurrentQty)
myConnection.Close()