0

I've been trying to resolve a problem but i'm stuck. I am using visual studio 2015 and mysql. I have a combobox that displays boxno. I store the boxno respectively in two tables : Doc and Delivery. In the combobox I want to display boxno from Doc except the ones stored in Delivery. Here's what i tried so far but it returns blank. Please help!

 mycommand = New MySqlCommand(
                 "select boxno from Doc where docStatus='" + 
                 cmbDocStatus.Text + 
                  "' and boxno not in (Select boxno from delivery) order by boxno asc"
                 , connexion)
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
Mark
  • 1
  • Hey Mark what is the problem?? The command look ok did you try run the query direct on the db first?, btw dont concatenate the text or you will be vulnarable to sql injection, always use paramaters like [**this**](https://stackoverflow.com/questions/652978/parameterized-query-for-mysql-with-c-sharp) – Juan Carlos Oropeza Jul 12 '17 at 16:18
  • Show us db schema, sample data and expected output. Please read [**How-to-Ask**](http://stackoverflow.com/help/how-to-ask) And here is a great place to [**START**](http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/) to learn how improve your question quality and get better answers. [**How to create a Minimal, Complete, and Verifiable example**](http://stackoverflow.com/help/mcve) – Juan Carlos Oropeza Jul 12 '17 at 16:19
  • Thanks guyz. I resolved it. here's my code now: – Mark Jul 12 '17 at 18:49
  • mycommand = New MySqlCommand("select boxno from Doc L where docstatus=@docStatus and boxno not in (Select boxno from delivery where delivery.boxno = L.boxno) and L.boxno<>''", connexion) – Mark Jul 12 '17 at 18:53

0 Answers0