I am trying to pass a variable "PIN2" that I am retrieving like below to开发者_StackOverflow a SelectCommand statement in a asp SqlDataSource tag
<%
Dim PIN As String = Request.ServerVariables("LOGON_USER") Dim PIN2 As String = Right(PIN, 6) %>
Thanks
How about refactoring your PIN to your code-behind in a Session Variable and then using it inside your SQLDataSource tag as a SessionParameter.
Like this:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="vb" >
Partial Class MyPending
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim PIN As String = Request.ServerVariables("LOGON_USER")
Dim PIN2 As String = Right(PIN, 6)
Session("PIN") = PIN2
End Sub
End Class
</script>
.
<asp:sqldatasource id="SqlDataSource1" runat="server" selectcommand="... WHERE USERPIN=@thepin">
<selectparameters>
<asp:sessionparameter sessionfield="PIN" type="String" name="thepin" />
</selectparameters>
</asp:sqldatasource>
精彩评论