I'm creating an inventory system which should display the products that needs to be restock. If the quantity of the product is only 10 it should display a message that says you need to restock now. But I don't know how to do that I'm sorry, hope u guys understand.

here's my table
http://imgur.com/jpjLYVy

Recommended Answers

All 2 Replies

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString = "server=localhost;userid=root;password=root;database=taihsin_inventory"
        Dim Reader As MySqlDataReader
        Try
            MysqlConn.Open()
            Dim query As String
            query = "select quantiy from taihsin_inventory where quantiy < 100"
            COMMAND = New MySqlCommand(query, MysqlConn)
            Reader = COMMAND.ExecuteReader
            While Reader.Read
                MessageBox.Show("Following products quantity is less than 100\n"+
            End While
        Catch ex As Exception

        End Try
        where my current code.

There are some mistakes in conception to read data from datareader object. If the reader contains no data it can't give you any result. So, you have to check first it contains any record or not.
The codes should be

MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString = "server=localhost;userid=root;password=root;database=taihsin_inventory"
        Dim Reader As MySqlDataReader
        Try
            MysqlConn.Open()
            Dim query As String
            query = "select quantiy from taihsin_inventory where quantiy < 10"
            Dim COMMAND As MySqlCommand= New MySqlCommand(query, MysqlConn)
            Reader = COMMAND.ExecuteReader()
            If Reader.HasRows() Then
                Do Reader.Read()
                    MessageBox.Show("Following products quantity is less than 100\n"+
                Loop
            End If
            Reader.Close()
            Reader.Dispose()
            COMMAND.Dispose()
        Catch ex As Exception
        End Try

Hope, it can help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.