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

  • Home
  • SEARCH
  • 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

Using VS 2008, I have a Repeater control: <asp:Repeater runat=server ID=storesRep DataSourceID=storeSqlDataSource OnItemDataBound=StoresRep_ItemDataBound> <ItemTemplate>
I have ASP.NET web pages for which I want to build automated tests (using
I have asp.net form that contains fields. When I access this window, my javascript
I have a ASP.NET page with an asp:button that is not visible. I can't
I have a ASP.NET application that we've written our own logging module for. My
I'm using Asp.net and have just started to look for a tab solution and
I have a page in asp.net (web forms) that up until now only had
I have a SqlDataSource that returns 1 field (1 row) for an ID. I
I have defined a nested grid view in the following way. <asp:GridView ID=GridView1 runat=server
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>

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.