Dynamic create sql statement in aspDatasource RRS feed

  • Question

  • User-473207793 posted


    I am trying to create an ASP AccessDataSource tag with the following characteristics: I would like to read the querystring for my where parameter. I am using the following syxntax:

    Dim sqlstatement as String = "select * from Lista WHERE Profesion ='" & request.querystring("Profesion") & "' ORDER BY Lista.APELLIDOS_Y_NOMBRES"
    response.write (sqlstatement)  


    <asp:AccessDataSource id="AccessDataSource1" runat="server" DataFile="XXXXX" SelectCommand="<% sqlstatement %>" > </asp:AccessDataSource>


    The SQL statement is well formed but it does not seem to like the fact that I want to introduce a variable. Any suggestions?


    Wednesday, December 15, 2010 12:32 PM