Parser error

Last post 06-20-2009 10:16 AM by limno. 2 replies.

Sort Posts:

  • Parser error

    06-20-2009, 12:15 AM
    • Member
      11 point Member
    • pthakar
    • Member since 02-18-2009, 11:37 PM
    • Posts 67
    <asp:DropDownList ID="ddlyr" runat="server" Width="200"

    DataSourceID="srcyr" DataTextField="year" >

    </asp:DropDownList>

    <asp:SqlDataSource ID="srcyr" runat ="server"

    ConnectionString="<%$ ConnectionStrings:StudetsConnectionString %>"

    SelectCommand="select year from tyear">

    </asp:SqlDataSource>

     

    I am trying to bind these two colum but system is giving me parser error --any one have any idea?

    here's the code:-

     

    <asp:DropDownList ID="ddlorg" runat="server" DataSource="srcOrg"

    DataTextField="org" DataValueField="year">

    </asp:DropDownList>

    <asp:SqlDataSource ID="srcOrg" runat ="server"

    ConnectionString="<%$ ConnectionStrings:StudetsConnectionString %>"

    SelectCommand="select org from org where year=2003">

     

    </asp:SqlDataSource>

    c2
    Filed under:
  • Re: Parser error

    06-20-2009, 5:51 AM
    Answer


    1. In srcOrg datasource, you are fetching only "org"  column, but in ddlorg dropdownlist, datavaluefield is "year" which you are not selecting from that datasource.

     

    2. Is your web config has a connection string, "StudetsConnectionString"

     

    3. Is it studentsconnectionstring or studetsconnectionstring?

     

    if still not solved, post your detailed exact error. if possible, post screen shot of that error.

    Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
  • Re: Parser error

    06-20-2009, 10:16 AM
    Answer
    • All-Star
      87,101 point All-Star
    • limno
    • Member since 06-10-2005, 3:50 PM
    • Iowa, USA
    • Posts 4,947
    • Moderator
      TrustedFriends-MVPs

    You should avoid the keyword as your column name.You can change the year column to something like myYear. Do the same for the frst one.

    DataValueField="myYear">

    select org, myYear from org where myYear=2003

    Limno

    Format your SQL query with instant sql formatter:
    http://www.dpriver.com/pp/sqlformat.htm
Page 1 of 1 (3 items)