How do I insert a local variable into a select statement when using the Oracle DB connecter in asp.net 2.0
Expand|Select|Wrap|Line Numbers
- In Code Behind: I set this the string to be the users id:
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
- Dim strNTUser As String
- Dim iPos As Integer
- strNTUser = RTrim(Request.ServerVariables("LOGON_USER"))
- iPos = Len(strNTUser) - InStr(1, strNTUser, "\", CompareMethod.Binary)
- strNTUser = Right(strNTUser, iPos)
- End Sub
- In ASP I try to use the value of strNTUser as the where clause condition:
- <asp:SqlDataSource ID="oraDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:oraDB %>" ProviderName="<%$ ConnectionStrings:oraDB.ProviderName %>" SelectCommand='SELECT * FROM "MY_ASSOCIATES" WHERE ("USERID" = :USERID)'>
- <SelectParameters>
- <asp:SessionParameter Name="USERID" SessionField="strNTUser" Type="String" />
- </SelectParameters>