Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. displaying problem

displaying problem

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-netsql-server
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    I am using asp.net with c# and sql server. well I have some syntax error problem. my code is:

    <asp:Repeater runat="server" id="Repeater1">
    <HeaderTemplate>Items<br /><br /></HeaderTemplate>
    <ItemTemplate>
     <b><%# DataBinder.Eval(Container.DataItem, "CatName") %></t>
                 
                 <asp:HiddenField  ID="HiddenField1" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' />
                 <asp:Repeater id="Repeater2" runat="server" DataSourceID="AccessDataSourceMembers">
                 <ItemTemplate>
                    <tr>
                    <br><%# DataBinder.Eval(Container.DataItem, "ItemName") %></br>
                    </tr>
                 </ItemTemplate>
                </asp:Repeater>
    

    <asp:SqlDataSource ID="AccessDataSourceMembers" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=catItem" SelectCommand="SELECT * FROM items Where cat_ID = ?">
    <SelectParameters>
    <asp:ControlParameter Name="ID" ControlID="HiddenField1" PropertyName="Value" Type="string" />

    </SelectParameters> 
    

    </asp:SqlDataSource>

    </ItemTemplate>
          <separatortemplate>
             <br />
             <br />
             <br />
           </separatortemplate>
        </asp:Repeater>
    

    and the error it is showing is: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '?'. Source Error: Line 1197: objDA.Fill(ds); Line 1198: Repeater1.DataSource = ds; Line 1199: Repeater1.DataBind(); Line 1200: Line 1201: Note:If I do not use the nested repeater, it is working fine. So Can anyone tell me why is that error and how to get out of it??

    suchita

    Y S A 3 Replies Last reply
    0
    • D Dhyanga

      I am using asp.net with c# and sql server. well I have some syntax error problem. my code is:

      <asp:Repeater runat="server" id="Repeater1">
      <HeaderTemplate>Items<br /><br /></HeaderTemplate>
      <ItemTemplate>
       <b><%# DataBinder.Eval(Container.DataItem, "CatName") %></t>
                   
                   <asp:HiddenField  ID="HiddenField1" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' />
                   <asp:Repeater id="Repeater2" runat="server" DataSourceID="AccessDataSourceMembers">
                   <ItemTemplate>
                      <tr>
                      <br><%# DataBinder.Eval(Container.DataItem, "ItemName") %></br>
                      </tr>
                   </ItemTemplate>
                  </asp:Repeater>
      

      <asp:SqlDataSource ID="AccessDataSourceMembers" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=catItem" SelectCommand="SELECT * FROM items Where cat_ID = ?">
      <SelectParameters>
      <asp:ControlParameter Name="ID" ControlID="HiddenField1" PropertyName="Value" Type="string" />

      </SelectParameters> 
      

      </asp:SqlDataSource>

      </ItemTemplate>
            <separatortemplate>
               <br />
               <br />
               <br />
             </separatortemplate>
          </asp:Repeater>
      

      and the error it is showing is: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '?'. Source Error: Line 1197: objDA.Fill(ds); Line 1198: Repeater1.DataSource = ds; Line 1199: Repeater1.DataBind(); Line 1200: Line 1201: Note:If I do not use the nested repeater, it is working fine. So Can anyone tell me why is that error and how to get out of it??

      suchita

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      SayamiSuchi wrote:

      SELECT * FROM items Where cat_ID = ?

      it is complaining about your query. Are you sure that is what you want.

      Yusuf May I help you?

      D 1 Reply Last reply
      0
      • Y Yusuf

        SayamiSuchi wrote:

        SELECT * FROM items Where cat_ID = ?

        it is complaining about your query. Are you sure that is what you want.

        Yusuf May I help you?

        D Offline
        D Offline
        Dhyanga
        wrote on last edited by
        #3

        isn't the query was right ? I am new to repeater template tool and i am trying to use nested repeater. it gave those errors.

        suchita

        M 1 Reply Last reply
        0
        • D Dhyanga

          isn't the query was right ? I am new to repeater template tool and i am trying to use nested repeater. it gave those errors.

          suchita

          M Offline
          M Offline
          Martin Jarvis
          wrote on last edited by
          #4

          SELECT * FROM items Where cat_ID = ? Is an Oracle format query not TSQL. How you go about fixing this depends on what database your using. If it's SQL Server, then you'll need to amend the query to use the proper format (named parameters). If it's oracel then you'll need to swap out the datasource for the Oracle equivelent


          Freestyle Interactive Ltd  Martin on .Net  Follow Me on Twitter

          1 Reply Last reply
          0
          • D Dhyanga

            I am using asp.net with c# and sql server. well I have some syntax error problem. my code is:

            <asp:Repeater runat="server" id="Repeater1">
            <HeaderTemplate>Items<br /><br /></HeaderTemplate>
            <ItemTemplate>
             <b><%# DataBinder.Eval(Container.DataItem, "CatName") %></t>
                         
                         <asp:HiddenField  ID="HiddenField1" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' />
                         <asp:Repeater id="Repeater2" runat="server" DataSourceID="AccessDataSourceMembers">
                         <ItemTemplate>
                            <tr>
                            <br><%# DataBinder.Eval(Container.DataItem, "ItemName") %></br>
                            </tr>
                         </ItemTemplate>
                        </asp:Repeater>
            

            <asp:SqlDataSource ID="AccessDataSourceMembers" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=catItem" SelectCommand="SELECT * FROM items Where cat_ID = ?">
            <SelectParameters>
            <asp:ControlParameter Name="ID" ControlID="HiddenField1" PropertyName="Value" Type="string" />

            </SelectParameters> 
            

            </asp:SqlDataSource>

            </ItemTemplate>
                  <separatortemplate>
                     <br />
                     <br />
                     <br />
                   </separatortemplate>
                </asp:Repeater>
            

            and the error it is showing is: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '?'. Source Error: Line 1197: objDA.Fill(ds); Line 1198: Repeater1.DataSource = ds; Line 1199: Repeater1.DataBind(); Line 1200: Line 1201: Note:If I do not use the nested repeater, it is working fine. So Can anyone tell me why is that error and how to get out of it??

            suchita

            S Offline
            S Offline
            Stoffy1972
            wrote on last edited by
            #5

            Maybe this is not the easiest solution, but it works for me...

                <asp:Repeater runat="server" ID="Repeater1" DataSourceID="dsLocations">
                    <HeaderTemplate>
                        Items<br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <b><%# DataBinder.Eval(Container.DataItem, "City") %></b> <b><%# DataBinder.Eval(Container.DataItem, "State") %></b>
                        <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"LocationID") %>' />
                        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="dsUserData">
                            <ItemTemplate>
                                <p>
                                    <%# DataBinder.Eval(Container.DataItem, "LastName") %>,
                                    <%# DataBinder.Eval(Container.DataItem, "FirstName") %></br>
                                </p>
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:SqlDataSource ID="dsUserData" runat="server" 
                            ConnectionString="server=.\\SQLEXPRESS;Initial Catalog=LinqTest;Integrated Security=true" 
                            SelectCommand="SELECT \* FROM UserData Where LocationID = @LocationID"
                            OnSelecting="dsUserData\_Selecting">
                            <SelectParameters>
                                <asp:Parameter Name="LocationID" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        <br />
                        <br />
                        <br />
                    </SeparatorTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="dsLocations" runat="server" ConnectionString="server=.\\SQLEXPRESS;Initial Catalog=LinqTest;Integrated Security=true" SelectCommand="SELECT \* FROM Location"></asp:SqlDataSource>
            

            Code behind:

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Web;
            using System.Web.UI;
            using System.Web.UI.WebControls;

            public partial class _Default : System.Web.UI.Page
            {
            protected void Page_Load(object sender, EventArgs e)
            {
            }

            protected void dsUserData\_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
            {
                HiddenField hf = Repeater1.Controls\[1\].F
            
            D 1 Reply Last reply
            0
            • D Dhyanga

              I am using asp.net with c# and sql server. well I have some syntax error problem. my code is:

              <asp:Repeater runat="server" id="Repeater1">
              <HeaderTemplate>Items<br /><br /></HeaderTemplate>
              <ItemTemplate>
               <b><%# DataBinder.Eval(Container.DataItem, "CatName") %></t>
                           
                           <asp:HiddenField  ID="HiddenField1" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' />
                           <asp:Repeater id="Repeater2" runat="server" DataSourceID="AccessDataSourceMembers">
                           <ItemTemplate>
                              <tr>
                              <br><%# DataBinder.Eval(Container.DataItem, "ItemName") %></br>
                              </tr>
                           </ItemTemplate>
                          </asp:Repeater>
              

              <asp:SqlDataSource ID="AccessDataSourceMembers" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=catItem" SelectCommand="SELECT * FROM items Where cat_ID = ?">
              <SelectParameters>
              <asp:ControlParameter Name="ID" ControlID="HiddenField1" PropertyName="Value" Type="string" />

              </SelectParameters> 
              

              </asp:SqlDataSource>

              </ItemTemplate>
                    <separatortemplate>
                       <br />
                       <br />
                       <br />
                     </separatortemplate>
                  </asp:Repeater>
              

              and the error it is showing is: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '?'. Source Error: Line 1197: objDA.Fill(ds); Line 1198: Repeater1.DataSource = ds; Line 1199: Repeater1.DataBind(); Line 1200: Line 1201: Note:If I do not use the nested repeater, it is working fine. So Can anyone tell me why is that error and how to get out of it??

              suchita

              A Offline
              A Offline
              aswinnnnnnn
              wrote on last edited by
              #6

              u hav to write in line no 1197---->>> objda.fill(ds,"tablename"); i gave suggestin on my best knowldge......... tried once.............

              1 Reply Last reply
              0
              • S Stoffy1972

                Maybe this is not the easiest solution, but it works for me...

                    <asp:Repeater runat="server" ID="Repeater1" DataSourceID="dsLocations">
                        <HeaderTemplate>
                            Items<br />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <b><%# DataBinder.Eval(Container.DataItem, "City") %></b> <b><%# DataBinder.Eval(Container.DataItem, "State") %></b>
                            <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"LocationID") %>' />
                            <asp:Repeater ID="Repeater2" runat="server" DataSourceID="dsUserData">
                                <ItemTemplate>
                                    <p>
                                        <%# DataBinder.Eval(Container.DataItem, "LastName") %>,
                                        <%# DataBinder.Eval(Container.DataItem, "FirstName") %></br>
                                    </p>
                                </ItemTemplate>
                            </asp:Repeater>
                            <asp:SqlDataSource ID="dsUserData" runat="server" 
                                ConnectionString="server=.\\SQLEXPRESS;Initial Catalog=LinqTest;Integrated Security=true" 
                                SelectCommand="SELECT \* FROM UserData Where LocationID = @LocationID"
                                OnSelecting="dsUserData\_Selecting">
                                <SelectParameters>
                                    <asp:Parameter Name="LocationID" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </ItemTemplate>
                        <SeparatorTemplate>
                            <br />
                            <br />
                            <br />
                        </SeparatorTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="dsLocations" runat="server" ConnectionString="server=.\\SQLEXPRESS;Initial Catalog=LinqTest;Integrated Security=true" SelectCommand="SELECT \* FROM Location"></asp:SqlDataSource>
                

                Code behind:

                using System;
                using System.Collections.Generic;
                using System.Linq;
                using System.Web;
                using System.Web.UI;
                using System.Web.UI.WebControls;

                public partial class _Default : System.Web.UI.Page
                {
                protected void Page_Load(object sender, EventArgs e)
                {
                }

                protected void dsUserData\_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
                {
                    HiddenField hf = Repeater1.Controls\[1\].F
                
                D Offline
                D Offline
                Dhyanga
                wrote on last edited by
                #7

                But in user control page,can we use hiddenfield ? Mine is not taking that ...I tried this one too..

                suchita

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups