Morning,
I've been scouring the forumsa and tutorials and I think I'm close. I'm trying to collect the username ofthe user connecting to the webapage (this is an intranet app) and submit it via a sql statement. My confusion is where you put what. On the default.aspx.vb I have a proteced sub page load and I have this code in it:
Then on the default.aspx I have some more code that tells how to connect to sql. The problem is that the logon_user id is never being populated to put into the statement.
The IIS server is set to windows authenticated. If anyone can help I would really appreciate it.
Thanks
Laura
I've been scouring the forumsa and tutorials and I think I'm close. I'm trying to collect the username ofthe user connecting to the webapage (this is an intranet app) and submit it via a sql statement. My confusion is where you put what. On the default.aspx.vb I have a proteced sub page load and I have this code in it:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Get the Logged on user
' Make sure Anonymous is not checked in IIS Manager
' otherwise this may be empty
Dim strLogonUsr As String
strLogonUsr = Request.ServerVariables("LOGON_USER")
' Create new parameters for the SqlCommand object and
' initialize them to the field values.
' Create the parameter for the logon user
myCommand.Parameters.Add(New SqlParameter("@Logon_User", _SqlDbType.VarChar, 50))
' Assign the value
myCommand.Parameters("@Logon_User").Value = strLogonUsr
' Create the parameter for the time
myCommand.Connection.Open()
End Sub
Then on the default.aspx I have some more code that tells how to connect to sql. The problem is that the logon_user id is never being populated to put into the statement.
The IIS server is set to windows authenticated. If anyone can help I would really appreciate it.
Thanks
Laura