Question Locked

Inserting Variables In ASP.NET

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi,

I am trying to insert the username of a user into my database whe he/she creates a record or modifies one. the inbuilt SQL function either returns "dbo" or "sa". I need to insert the current username using a variable. it may be easy for you guys but for some reason i am unable to do so. can you please help. the username is not fed through any control but through a simple variable. how do i reference it in my query.

This problem is driving me batty. please help

4 replies

by bschaettle

This is what I use to capture the network Username.

========================================
Imports System.Security
Imports System.Security.Principal
...
...
Dim sNetwork_Username As String = _
Context.User.Identity.Name

by ydobonmai

Thanks for your help. I'll try it out. however, that still leaves me with the SQL.

I have a field First_Name, so I'll reference it in my query as @First_Name. How do i do that for a variable -

Dim lastname As string
lastname = "Evans"

How do i get the above into the database???

@lastname???

Please help

by Member 22070467

If you are using integrated security, the SYSTEM_USER sql function will return their windows login name. If you are using standard sql accounts as the connection, it will return what sql account is being used.

This discussion is closed to new replies.