DropDownList to populate from MySQL db using specific filter












0















I am trying to populate a DropDownList from MySQL db. It's working fine, however I am trying to apply one filter there.

The program I am developing is a POS software so the DropDownList should only populate from MySQL if the inventory has more than 0 items available for sale.



Clicking on a "+" button populates the DropDownList from MySQL db.



Here's the code for that button:





Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New MySqlConnection("server=localhost;userid=root;password=;database=chanamotors")
Dim adapter As New MySqlDataAdapter("SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory", connection)
Dim table As New DataTable()
adapter.Fill(table)

BunifuDropdown1.DataSource = table
BunifuDropdown1.ValueMember = "itemname"
BunifuDropdown1.DisplayMember = "itemname"
End Sub


Now I am trying to add a filer like if quantity = 0 then the item name won't be displayed on the dropdown list.










share|improve this question




















  • 1





    Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

    – ADyson
    Nov 14 '18 at 23:03













  • thanks, my bad I am weak in mysql commands. thank you so much

    – Rik Namchoom
    Nov 14 '18 at 23:05






  • 1





    Understood about the root part as well. Noted.

    – Rik Namchoom
    Nov 14 '18 at 23:16
















0















I am trying to populate a DropDownList from MySQL db. It's working fine, however I am trying to apply one filter there.

The program I am developing is a POS software so the DropDownList should only populate from MySQL if the inventory has more than 0 items available for sale.



Clicking on a "+" button populates the DropDownList from MySQL db.



Here's the code for that button:





Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New MySqlConnection("server=localhost;userid=root;password=;database=chanamotors")
Dim adapter As New MySqlDataAdapter("SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory", connection)
Dim table As New DataTable()
adapter.Fill(table)

BunifuDropdown1.DataSource = table
BunifuDropdown1.ValueMember = "itemname"
BunifuDropdown1.DisplayMember = "itemname"
End Sub


Now I am trying to add a filer like if quantity = 0 then the item name won't be displayed on the dropdown list.










share|improve this question




















  • 1





    Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

    – ADyson
    Nov 14 '18 at 23:03













  • thanks, my bad I am weak in mysql commands. thank you so much

    – Rik Namchoom
    Nov 14 '18 at 23:05






  • 1





    Understood about the root part as well. Noted.

    – Rik Namchoom
    Nov 14 '18 at 23:16














0












0








0








I am trying to populate a DropDownList from MySQL db. It's working fine, however I am trying to apply one filter there.

The program I am developing is a POS software so the DropDownList should only populate from MySQL if the inventory has more than 0 items available for sale.



Clicking on a "+" button populates the DropDownList from MySQL db.



Here's the code for that button:





Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New MySqlConnection("server=localhost;userid=root;password=;database=chanamotors")
Dim adapter As New MySqlDataAdapter("SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory", connection)
Dim table As New DataTable()
adapter.Fill(table)

BunifuDropdown1.DataSource = table
BunifuDropdown1.ValueMember = "itemname"
BunifuDropdown1.DisplayMember = "itemname"
End Sub


Now I am trying to add a filer like if quantity = 0 then the item name won't be displayed on the dropdown list.










share|improve this question
















I am trying to populate a DropDownList from MySQL db. It's working fine, however I am trying to apply one filter there.

The program I am developing is a POS software so the DropDownList should only populate from MySQL if the inventory has more than 0 items available for sale.



Clicking on a "+" button populates the DropDownList from MySQL db.



Here's the code for that button:





Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New MySqlConnection("server=localhost;userid=root;password=;database=chanamotors")
Dim adapter As New MySqlDataAdapter("SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory", connection)
Dim table As New DataTable()
adapter.Fill(table)

BunifuDropdown1.DataSource = table
BunifuDropdown1.ValueMember = "itemname"
BunifuDropdown1.DisplayMember = "itemname"
End Sub


Now I am trying to add a filer like if quantity = 0 then the item name won't be displayed on the dropdown list.







mysql sql vb.net dropdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 21:37









Jimi

9,01241934




9,01241934










asked Nov 14 '18 at 22:48









Rik NamchoomRik Namchoom

115




115








  • 1





    Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

    – ADyson
    Nov 14 '18 at 23:03













  • thanks, my bad I am weak in mysql commands. thank you so much

    – Rik Namchoom
    Nov 14 '18 at 23:05






  • 1





    Understood about the root part as well. Noted.

    – Rik Namchoom
    Nov 14 '18 at 23:16














  • 1





    Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

    – ADyson
    Nov 14 '18 at 23:03













  • thanks, my bad I am weak in mysql commands. thank you so much

    – Rik Namchoom
    Nov 14 '18 at 23:05






  • 1





    Understood about the root part as well. Noted.

    – Rik Namchoom
    Nov 14 '18 at 23:16








1




1





Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

– ADyson
Nov 14 '18 at 23:03







Seems pretty trivial.... SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0 unless I've missed something in my understanding? BTW never get your applications to log in as "root", even for testing, it gives them far too much privilege. Instead create an account in SQL specifically for the application, with only the permissions it actually needs

– ADyson
Nov 14 '18 at 23:03















thanks, my bad I am weak in mysql commands. thank you so much

– Rik Namchoom
Nov 14 '18 at 23:05





thanks, my bad I am weak in mysql commands. thank you so much

– Rik Namchoom
Nov 14 '18 at 23:05




1




1





Understood about the root part as well. Noted.

– Rik Namchoom
Nov 14 '18 at 23:16





Understood about the root part as well. Noted.

– Rik Namchoom
Nov 14 '18 at 23:16












1 Answer
1






active

oldest

votes


















0














You can do it easily in the SQL command by adding a WHERE clause like this:



SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309886%2fdropdownlist-to-populate-from-mysql-db-using-specific-filter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can do it easily in the SQL command by adding a WHERE clause like this:



    SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0





    share|improve this answer




























      0














      You can do it easily in the SQL command by adding a WHERE clause like this:



      SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0





      share|improve this answer


























        0












        0








        0







        You can do it easily in the SQL command by adding a WHERE clause like this:



        SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0





        share|improve this answer













        You can do it easily in the SQL command by adding a WHERE clause like this:



        SELECT `itemname`, `itemcode`, `saleprice`, `quantity` FROM inventory WHERE quantity > 0






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 23:06









        ADysonADyson

        24.4k112545




        24.4k112545
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309886%2fdropdownlist-to-populate-from-mysql-db-using-specific-filter%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma