We help IT Professionals succeed at work.

Passing variables to a ms sql select line

saljas
saljas asked
on
60 Views
Last Modified: 2017-04-17
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?
Comment
Watch Question

Daniel Van Der WerkenIndependent Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Close the question

Author

Commented:
I could not find a solution

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions