J
John Graham
Brief background, I'm new to .net, and my train of thought is how do I
convert my asp scripting to work in .net.
I have asp code that is grabbing a old session variable and doing the
query against my sql db essentially letting someone update their
information in the db. When using a sql data source, I'm trying to
get it to access the user login name, preferably without the
DomainName\ part of DomainName\USERNAME.
My question is how do I access that username in the sql query?
My previous code was,
rsFaculty = Server.CreateObject("ADODB.Recordset")
rsFaculty.ActiveConnection = MM_DSNci_STRING
rsFaculty.Source = "SQL QUERY find.... Where ID" &
session("variable")
rsFaculty.CursorType = 0
rsFaculty.CursorLocation = 2
rsFaculty.LockType = 3
rsFaculty.Open()
rsFaculty_numRows = 0
I'm guessing the new would be something like...
page class
public strUsername as String =
httpContext.current.user.Identity.name.ToString
on page code
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connStrNAME %>"
SelectCommand="SELECT * FROM [tblFaculty] WHERE
([id] = " & strUseraname & ")">
</asp:SqlDataSource>
john
convert my asp scripting to work in .net.
I have asp code that is grabbing a old session variable and doing the
query against my sql db essentially letting someone update their
information in the db. When using a sql data source, I'm trying to
get it to access the user login name, preferably without the
DomainName\ part of DomainName\USERNAME.
My question is how do I access that username in the sql query?
My previous code was,
rsFaculty = Server.CreateObject("ADODB.Recordset")
rsFaculty.ActiveConnection = MM_DSNci_STRING
rsFaculty.Source = "SQL QUERY find.... Where ID" &
session("variable")
rsFaculty.CursorType = 0
rsFaculty.CursorLocation = 2
rsFaculty.LockType = 3
rsFaculty.Open()
rsFaculty_numRows = 0
I'm guessing the new would be something like...
page class
public strUsername as String =
httpContext.current.user.Identity.name.ToString
on page code
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connStrNAME %>"
SelectCommand="SELECT * FROM [tblFaculty] WHERE
([id] = " & strUseraname & ")">
</asp:SqlDataSource>
john