Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call Open_database()
        XSQL = "Select stock from item where itemcode like '" & Trim(TextBox2.Text) & "'"
        CMD = New OleDb.OleDbCommand(XSQL, CONN)
        CMD.ExecuteReader()

        If Missing Code Here
            MsgBox("Alert")

        Else
            XSQL = "Update item set Stock = Stock - " & Trim(TextBox1.Text) & " where itemcode like '" & Trim(TextBox2.Text) & "' and stock > 0"
            CMD = New OleDb.OleDbCommand(XSQL, CONN)
            CMD.ExecuteNonQuery()
            CMD.Dispose()
            CONN.Close()
            MsgBox("Alert", MsgBoxStyle.Information)
    End Sub

hello..i might need some help here..i need to make a Condition where if my item is less than 0 then a msgbox will pop up...can any1 help me ? thx.

Edited 6 Years Ago by __avd: Added [code] tags.

I mean..how do i get the value from the database where itemcode like value of textbox
and label = value(from database that i got)
ty ty

Edited 6 Years Ago by LeafProduction: n/a

XSQL = "Select stock from item where itemcode ='" & Trim(TextBox2.Text) & "'"
CMD = New OleDb.OleDbCommand(XSQL, CONN)
Dim obj as OleDbDataReader
Dim found as boolean=false

obj=CMD.ExecuteReader()
if obj.Read() Then
   found=true
End if
obj.Close()

If Not Found Then
  MsgBox("Alert")

Else
 XSQL = "Update item set Stock = Stock - " & Trim(TextBox1.Text) & " where itemcode like '" & Trim(TextBox2.Text) & "' and stock > 0"
 CMD = New OleDb.OleDbCommand(XSQL, CONN)
 CMD.ExecuteNonQuery()
 CMD.Dispose()
 CONN.Close()
 MsgBox("Alert", MsgBoxStyle.Information)
End Sub
This article has been dead for over six months. Start a new discussion instead.