problem parameters in sqldatasource

  • Thread starter Thread starter Julien Sobrier
  • Start date Start date
J

Julien Sobrier

Hello,
I'm facing a very simple problem. This DataSource returns the right result:
<asp:SqlDataSource ID="SqlSons" runat="server" EnableCaching=true
SelectCommand="SELECT no, titrefr FROM structure WHERE
parent= 74ORDER BY no DESC" />

But when I try to use an SalParameters, there is no result:
<asp:SqlDataSource ID="SqlSons" runat="server" EnableCaching=true
SelectCommand="SELECT no, titrefr FROM structure WHERE
parent= @Parent ORDER BY no DESC" >
<SelectParameters>
<asp:Parameter Name="Parent" DefaultValue="74" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

Is there an additional step needed for the SqlDataSource to replace
@Parent by the DefaultValue of the Select Parameter Parent?


The "full" code is this:

<asp:SqlDataSource ID="SqlSons" runat="server" EnableCaching=true
SelectCommand="SELECT no, titrefr FROM structure WHERE
parent= @Parent ORDER BY no DESC" >
<SelectParameters>
<asp:Parameter Name="Parent" DefaultValue="74" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

<ol>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlSons">
<ItemTemplate>
<li><%# Eval("titrefr") %></li>
</ItemTemplate>
</asp:Repeater>
</ol>

Thank you
Julien
 
Julien said:
Hello,
I'm facing a very simple problem. This DataSource returns the right result:
<asp:SqlDataSource ID="SqlSons" runat="server" EnableCaching=true
SelectCommand="SELECT no, titrefr FROM structure WHERE
parent= 74ORDER BY no DESC" />

But when I try to use an SalParameters, there is no result:
<asp:SqlDataSource ID="SqlSons" runat="server" EnableCaching=true
SelectCommand="SELECT no, titrefr FROM structure WHERE
parent= @Parent ORDER BY no DESC" >
<SelectParameters>
<asp:Parameter Name="Parent" DefaultValue="74" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

Is there an additional step needed for the SqlDataSource to replace
@Parent by the DefaultValue of the Select Parameter Parent?

I didn't realize that with MySQL, I need to use ? instead of @
 
Back
Top