Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What is the context? WPF application?</p> <p>If your tested request is ok, just use the string inside the way "you use like":</p> <pre><code>string strQuery = "SELECT * FROM Purchase where ItemID=(SELECT ItemID FROM ItemMaster where ItemName='" + DropDownList3.SelectedItem.Text + "' and CategoryID=(SELECT CategoryID FROM ItemMaster where ItemName='" + DropDownList3.SelectedItem.Text + "')"; SqlDataAdapter daSearch = new SqlDataAdapter(strQuery, conn); </code></pre> <p>You also made mistakes with the " and ' in your previous version.</p> <p>For a better response, please update your question with: - info about your whole solution (type of application, environment) - info about your datamodel, because your request does not seem to be well written</p> <p><strong>EDIT 1 after your comments:</strong></p> <p>your problem is that you don't know how to get the value of the selected item in your comboBox. See here for difference between SelectedItem, SelectedValue... <a href="http://blogs.msdn.com/b/jaredpar/archive/2006/11/07/combobox-selecteditem-selectedvalue-selectedwhat.aspx?Redirected=true" rel="nofollow">http://blogs.msdn.com/b/jaredpar/archive/2006/11/07/combobox-selecteditem-selectedvalue-selectedwhat.aspx?Redirected=true</a></p> <p>Once you will be ready to read these values, create your query in a string like this</p> <pre><code>string myRequest = "SELECT companyName FROM table where mainCategory = '" + *value of mainCatU* + "' and subcategory = '" + *value of subCatU* + "'"; </code></pre> <p>Then pass the string to SQL and get the results: SqlDataAdapter daSearch = new SqlDataAdapter(myRequest, conn);</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload