Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues with NpgsqlDatareader when trying to integrate Vb.net with PostgreSQL database
    primarykey
    data
    text
    <p>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.</p> <h2>|barcode|item|type|received|removed|on_hand|</h2> <h2>|ien0001|thing1|type1| 1 | 2 | 3 |</h2> <h2>|ien0002|thing2|type2| 4 | 5 | 6 |</h2> <h2>|ien0003|thing1|type1| 7 | 8 | 9 |</h2> <p>Example of my table </p> <p>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. </p> <p>Thanks </p> <p>Also if I don't hardcode the barcode then (no pun intended) then the if statement is never executed. </p> <p>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.</p> <p>If there is another way of doing this please let me know. Thanks</p> <p>mySQLString = "SELECT On_Hand FROM total_inventory WHERE Barcode = 'ien0002' ;"</p> <pre><code> 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(":" &amp; CurrentQty) End If myReader.Close() MsgBox(CurrentQty) myConnection.Close() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload