0
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 by __avd: Added [code] tags.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by __avd
0

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 by LeafProduction: n/a

0
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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.