Note that there are some explanatory texts on larger screens.

plurals
  1. POpopulating dropdowns in aspx. Conversion failed
    primarykey
    data
    text
    <p>I have two dropdowns in aspx page one for location and vendors. Based on the value selected in the location dropdown, The vendors dropdown must populate...I am trying to bind with location name </p> <p>Location:</p> <pre><code> &lt;asp:DropDownList ID="ddlAllLocations" runat="server" DataSourceID="SqlDataSourceBusinessLocations" DataTextField="Location_Name" DataValueField="Location_ID" AutoPostBack="True" AppendDataBoundItems="True"&gt; &lt;asp:ListItem value="" selected="True"&gt; </code></pre> <p>Vendors :</p> <pre><code>&lt;asp:SqlDataSource ID="SqlDataSourceAllVendors" runat="server" ConnectionString="&lt;%$ ConnectionStrings:xxxxx %&gt;" ProviderName="&lt;%$ ConnectionStrings:xxxxx.ProviderName %&gt;" SelectCommand="GetAllVendorsForBUforLocation" SelectCommandType="StoredProcedure"&gt; &lt;SelectParameters&gt; &lt;asp:SessionParameter Name="userBUIds" SessionField="BusinessUnitIds" Size="200" Type="String" /&gt; &lt;asp:ControlParameter ControlID="ddlAllLocations" Name="LOCATION_ID" PropertyName="SelectedValue" Type="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>My stored procedure is </p> <pre><code>-- ============================================= ALTER PROCEDURE [dbo].[GetAllVendorsForBUforLocation] @userBUIds varchar(200), @LOCATION_ID int AS DECLARE @sql NVARCHAR(4000) BEGIN set @sql='SELECT DISTINCT tblVendor_Payees.PayeeID, RTRIM(ISNULL(a.Name1_Last, '''')) + '' '' + ISNULL(a.Name1_First, '''') AS VendorName, tblVendor_Business.BusinessID FROM tblVendor_Payees AS a left JOIN tblFields AS f ON a.PayeeID = f.VendorID INNER JOIN tblVendor_Business ON a.PayeeID = tblVendor_Business.PayeeID INNER JOIN INVENTORY.TBL_LOCATION on INVENTORY.TBL_LOCATION.BusinessID = tblVendor_Business.BusinessID WHERE (a.VendorType = 1) AND (tblVendor_Business.BusinessID = '+cast(@userBUIds as varchar(50))+' and INVENTORY.TBL_LOCATION.LOCATION_ID = '+cast(@LOCATION_ID as int)+') ORDER BY VendorName' exec sp_executeSQL @sql END </code></pre> <p>I am getting this error :</p> <p>Conversion failed when converting the varchar value 'SELECT DISTINCT tblVendor_Payees.PayeeID, RTRIM(ISNULL(a.Name1_Last, '')) + ' ' + ISNULL(a.Name1_First, '') AS VendorName, tblVendor_Business.BusinessID FROM tblVendor_Payees AS a left JOIN tblFields AS f ON a.PayeeID = f.VendorID INNER JOIN tblVendor_Business ON a.PayeeID = tblVendor_Business.PayeeID INNER JOIN INVENTORY.TBL_LOCATION on INVENTORY.TBL_LOCATION.BusinessID = tblVendor_Business.BusinessID WHERE (a.VendorType = 1) AND (tblVendor_Business.BusinessID = 2 and INVENTORY.TBL_LOCATION.LOCATION_ID = ' to data type int</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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