displaying problem
-
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
-
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
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?
-
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?
-
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
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
-
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
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
-
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
u hav to write in line no 1197---->>> objda.fill(ds,"tablename"); i gave suggestin on my best knowldge......... tried once.............
-
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