Hi,
I have a GridView which is bound to a SqlDataSource that connects to Oracle. Here's the code:
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:OracleConnectionString%>" ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName%>" SelectCommand="SELECT QUIZ.TITLE FROM QUIZ WHERE (QUIZ.USERNAME = @.UserName)"
<SelectParameters>
<asp:SessionParameter Name="UserName" SessionField="currentUser" Type="String" />
</SelectParameters
</asp:SqlDataSource>
As you can see I'm trying to pass the value of the "currentUser" session variable to the query. I get an error message "ORA-xxx Illegal name/variable". Where am I going wrong? I tested the connection by placing a specific value instead of the "@.UserName" and it worked.
That is because Oracle Server doesn't use @. as a prefix for a parameter, it uses a colon (:).
Take a look at this example:
http://www.oracle.com/technology/oramag/oracle/05-sep/o55odpnet.html
No comments:
Post a Comment