Jynx Jynx - 7 months ago 11
SQL Question

SQL Select throwing exception, saying Data doesn't exist

STSQL = "select STOCKROOM_QTY from mpcs.si_mtipart_info where inv_type = '" & rsMPCS("inv_type") & "' and mti_part_no = '" & rsMPCS("mti_part_no") & "'"
rsMPCS2 = MPCS_SELECT_SQL(UCase(STSQL))
If rsMPCS2.HasRows Then
Dim CurrentQuan As Long = rsMPCS2("STOCKROOM_QTY")

STSQL = "update mpcs.si_mtipart_info set STOCKROOM_QTY = " & (CurrentQuan - NumericUpDown1.Value) & " where inv_type = '" & rsMPCS("inv_type") & "' and mti_part_no = '" & rsMPCS("mti_part_no") & "'"
MPCS_UPDATE_SQL(UCase(STSQL))


The above code is part of a from that is changing the STOCKROOM_QTY on an Oracle table.

The error I am getting is enter image description here

However if I run the select statement it is sending
select STOCKROOM_QTY from mpcs.si_mtipart_info where inv_type = MACH_PART' and mti_part_no = '01400010005'


You can see it exist.

enter image description here

Answer

It appears that you are using a data reader. In that case, you must call its Read method before accessing any data.