Morning,
I ma sure this is easy but asp.net is new for me. Anyway I’m trying to collect a username and put it into a SQL database. I collected the username just fine:
<% Dim strLogonUsr As String
Dim iPos As String
strLogonUsr = RTrim(Request.ServerVariables("LOGON_USER"))
iPos = Len(strLogonUsr) - InStr(1, strLogonUsr, "\\", 1)
strLogonUsr = Right(strLogonUsr, iPos)
%>
<p>Logon_User: <%Response.Write(Request.ServerVariables("LOGON_USER"))%></p>
<p>UserName: <%Response.Write(strLogonUsr)%></p>
So then I put it in the parameters:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>"
DeleteCommand="DELETE FROM [tbl_Inventory_Data] WHERE [Inv_Key] = @Inv_Key"
InsertCommand="INSERT INTO [tbl_Inventory_Data] ([Location], [PartNumber], [Quantity], [userName]) VALUES (@Location, @PartNumber, @Quantity, @strLogonUsr)"
SelectCommand="SELECT [Inv_Key], [Location], [PartNumber], [Quantity], [userName] FROM [tbl_Inventory_Data]"
UpdateCommand="UPDATE [tbl_Inventory_Data] SET [Location] = @Location, [PartNumber] = @PartNumber, [Quantity] = @Quantity, [userName] = @strLogonUsr WHERE [Inv_Key] = @Inv_Key">
<DeleteParameters>
<asp:Parameter Name="Inv_Key" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Location" Type="String" />
<asp:Parameter Name="PartNumber" Type="String" />
<asp:Parameter Name="Quantity" Type="Double" />
<asp:Parameter Name="strLogonUsr" Type="String" />
<asp:Parameter Name="Inv_Key" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Location" Type="String" />
<asp:Parameter Name="PartNumber" Type="String" />
<asp:Parameter Name="Quantity" Type="Double" />
<asp:Parameter Name="strLogonUsr" Type="String"/>
</InsertParameters>
</asp:SqlDataSource>
Then I tried numerous ways of trying to put it into a text box with no luck:
<asp:TextBox ID="userNameTextBox" runat="server"
Text=<%Response.Write(Request.ServerVariables("LOGON_USER"))%> />
Can someone tell me what goes in the text box? And if I have the variable set right?
Thanks for any help.
Laura