Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 278985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T01:19:37+00:00 2026-05-12T01:19:37+00:00

I have an ASP SqlDataSource connected to Sybase DB query, using Select Parameters that

  • 0

I have an ASP SqlDataSource connected to Sybase DB query, using Select Parameters that are populated by a dropdown:

Dropdown (works OK):

<asp:SqlDataSource ID="dsBondIDList" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
    SelectCommand="SELECT [name], [bondID] FROM [bonds]">
</asp:SqlDataSource>
<asp:DropDownList ID="lstBondID" runat="server" DataSourceID="dsBondIDList" DataTextField="name" DataValueField="bondID">

SqlDataSource with parameter:

    <asp:SqlDataSource ID="dsBonds" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
        SelectCommand="SELECT [ticker], [name], [isin], [currency], 
                       [stock], [maturity], [bid], [ask] 
                       FROM [bonds] where [bondID] = @bondID">
        <SelectParameters>
            <asp:ControlParameter Name="bondID" ControlID="lstBondID" PropertyName="SelectedValue" DefaultValue="-1" />
        </SelectParameters>    
    </asp:SqlDataSource>

But I get an error when I try to run it:

ERROR [HY000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Must declare  variable '@bondID'.

Which of course I would get it I ran the sql literally as displayed. I expect the ASP engine to do the substitution before sending the query (and to use the default value of lstBondID if necessary)

Does anybody know why the @bondID is not being substituted with the lstBondID.SelectedValue?

Thanks in advance

Ryan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T01:19:37+00:00Added an answer on May 12, 2026 at 1:19 am

    I just went through this problem 10 minutes ago and here’s the fix:

    If you need to keep using the ODBC driver you have, change your query to use ? instead of Named Parameters.

    SELECT [ticker], [name], [isin], [currency], 
    [stock], [maturity], [bid], [ask] 
    FROM [bonds] where [bondID] = ?
    

    The parameters are used in the order they are added to the parameters collection (This gets hairy when you need to use the parameter more than once in your query etc).

    Otherwise you can change drivers. Look for sybdrvodb.dll and regsvr32 it. Then setup your DSN and use that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code section below : <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MainConnStr %> SelectCommand=SELECT
I have the following SQLDataSource : <asp:SqlDataSource ID=topicSource runat=server ConnectionString=<%$ ConnectionStrings SelectCommandType=Text SelectCommand=SELECT *
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I dream of creating a control which works something like this: <asp:SqlDataSource id=dsFoo runat=server
I have an asp.net dropdown like this <asp:DropDownList width=95% ID=RessourceComposantes runat=server DataSourceID=Composantes DataTextField=Description DataValueField=ComposanteID>
I have the following itemTemplate in my datalist <ItemTemplate> <asp:LinkButton ID=LinkButton1 CommandName=Select autopostback=True runat=server>'<%#
Using VS 2008, I have a Repeater control: <asp:Repeater runat=server ID=storesRep DataSourceID=storeSqlDataSource OnItemDataBound=StoresRep_ItemDataBound> <ItemTemplate>
I have a SqlDataSource SelectCommand on my .aspx page. <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MyConnectionString
I have following code <asp:SqlDataSource ID=SqlDataSource1 runat=server UpdateCommand=UPDATE [gMeter] SET ... [userId] = @userId
I have ASP.NET web pages for which I want to build automated tests (using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.