Link to home
Start Free TrialLog in
Avatar of Salah a a a Al Jasem
Salah a a a Al JasemFlag for Kuwait

asked on

Passing variables to a ms sql select line

I am trying to pass the CustIdIs variable to the select line - I am using the following code which is not working

        <%
            Dim CustIdIs
            CustIdIs = Session("CustIdIs")
            Response.Write(CustIdIs)                  'this gives 2007-1 which is ok
        %>

        <asp:SqlDataSource ID="sourcename" runat="server"
            SelectCommand="SELECT Col1, col2, col3, col4 FROM Table WHERE Col0 = @CustIdIs "
            ConnectionString="<%$ ConnectionStrings:myConnectionString %>">
            <SelectParameters>
                <asp:Parameter DefaultValue="'<%=CustIdIs%>'" Name="CustIdIs" DbType="String" />  
            </SelectParameters>
        </asp:SqlDataSource>

But    if I replace @CustIdIs   with  '2007-1' it works fine
which means the value in the variable  CustIdIs  is not passed
Any Idea how to solve it?
SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Salah a a a Al Jasem

ASKER

Close the question
I could not find a solution