开发者

Membership and SQL question

开发者 https://www.devze.com 2023-03-07 20:23 出处:网络
I am thinking of following what buttons the user has pressed. I intend to choose the CreateUserWiz开发者_StackOverflow社区ard control that will create a database for me. The Membership class has got a

I am thinking of following what buttons the user has pressed. I intend to choose the CreateUserWiz开发者_StackOverflow社区ard control that will create a database for me. The Membership class has got a few functions to identify who the user is..e.g. GetUserNameByEmail..

What i am trying to do, is to track what each user has pressed and use his input for sqlCommand. For example, when the user presses the "post response" button, i want to record his identity and use it in sql to insert his message and identity..

The problem is that in the Users table that i made it has UserID as a primary key that identifies the user..and in the CreateUserWizard database or Membership cookie, it has its own functions fields.

So the question is how do i SELECT the users identity from the database/cookie created to me, and incorporate it into a statement in the SQL for my sqlStatement..

I need to obtain the identity of the user and use it in an SQL statement.. How can i achieve that?


You can grab the user_id from the Membership provider...

for example:

System.Web.Security.Membership.GetUser().ProviderUserKey

the will give you the user id of the current user - and you can use that value in your sql statement. If you're using the default Membership provider - this value will be a unique identifier (Guid) so:

Guid currentUserId = new Guid(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号