.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

how to pass membership userID to db table

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

 i'm using asp.net membership for logins/registeration. i have a bookings table with few fields, lets say first_name, last_name, product_name and userID.

when the user submits 'buy' i want to get the userID from the membership user tablem that way i know whose made the booking. i'll have these two tables (bookings & user tables) linked

but how do i get userID from the user table to pass to bookings table? i checked the membership class and it gives options like

-Membership.GetUser(), Membership.GetUserNameByEmail(), Membership.GetAllUsers() etc

nothing for getting user id. user id is stored like this: c1c91682-449f-45dd-b20e-3dac5315bba4

some suggestions how to do this, plz?




View Complete Post

More Related Resource Links

Pass ASP.NET membership identity object across domain?


I am trying to figure a way to SSO with ASP.NET membership and role model.

I can implement custom membership provider which consume web services hosting on a server.

With encryption of data. No problem.

But my question is, If I sign on a website with my provider, got my identity object on that application,

could I pass it to another website on another domain which use the same provider and by doing so, do not need to login again?

If this is possible, I am going to implement this solution. Please tell me what's your take on this.

=User!UserID from windows authentication using table from another database



i'm using sql server 2005, sql server business intelligence development studio for my reports and deploy them in my wss3.0 site.

what i'm trying to do is i'm trying to restrict wich users can see specific data within a report.

now, the thing is. the report gets the data out of my DB1 database and my windows authenticated user are in the WSS_content database.

when i deploy my report in my wss3 site. it gets the user that is loged in. but of course it does not display any data because the tables are not in the same database.

does someone knows how to do this?

Implementing a custom Membership Provider vs. using aspnet_Profile table - Which should I do?


I wanted to expand the amount of information that is associated with each user(MembershipUser) in the ASPNETDB.MDF database file. Adding columns like FirstName, LastName, etc. So I began implementing my own custom Membership Provider. I created a derived MembershipUser class with the extra private variables that I wanted each MembershipUser record to store. Its basically done. Almost after I did this I stumbled across the columns in the ASPNETDB.MDF->aspnet_Profile table called "PropertyNames" and "PropertyValuesString".  Could I have simply used these two columns to accomplish what I was attempting to do or are these columns for global application configuration settings?  

Is the aspnet_Profile table purpose to store expanded/related information about users such as personal information? Or is it for something else? Thanks.

Entities Data Models with multiple Categories using a membership table

(Using SQL Server 2008 and ASP.NET MVC2) I have a simple business table and a category table. I have a 3rd table to map business to category, a many-to-many relationship. the Map table contains a BusinessID and CategoryID. I'm lost as to how I can load the categories into my Business View Model using the entities model.Without incorporating categories, my code looks like this: var businessList = from b in entitiesDB.Businesses select new Models.BusinessViewModel { BusinessID = b.BusinessID, Name = b.Name } with Business View Model defined as: public class BusinessViewModel { [ScaffoldColumn(false)] public Guid BusinessID { get; set; } public string Name { get; set; } public List<Models.CategoryViewModel> Categories { get; set; } } but if i want to populate the Categories with the mapped categories, how would one do that?Thanks in advance for any help!

Using asp.net login control USERID to retrieve data from table using a where clause.


Protected Sub SqlDataSource1_inserting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting
        Dim MemUser As MembershipUser
        MemUser = Membership.GetUser()
        UserID.Text = MemUser.ProviderUserKey.ToString()
        e.Command.Parameters("@UserId").Value = MemUser.ProviderUserKey.ToString()

Best way to insert newly-created UserId into a second table also



I have set up the ASP.NET Membership system using MS SQL. I have also created a new table (Table2) in which the user can store additional information. The UserId column is present in both tables (Table2's UserId column is the foreign key to the UserId column in aspnet_Membership). When a new user creates their account, what is the best way to also automatically insert that user's unique UserId into a new Table2 record at the same time (obviously in the column UserId)?

Below is my attempt to do this. Not sure this is right, but I used the oncreateduser property of CreateUserWizard and called the method below -- not sure if it would work (but regardless, I'm getting the error message at bottom of this post). Please help.

Thank you.


Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)

            Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("MyDatabaseConnectionString").ToString())
                ' Create a command object.
                Dim cmd As New SqlCom

Referencing the membership user table


When creating a foreign key to the membership user table, is it better to refer to the user_id column or is it ok to use the username column?  I assume that the Membership spec enforces uniqueness in the username since there is a method Membership.GetUser(username) that returns one user.  Using the id is a bit awkward in code because I have to end up casting all over the place like (int)user.ProviderUserKey.  The username would give more information quickly when viewing raw data as well.  Just wondering if someone knows a reason why I shouldn't use it as the foreign key.



Membership userid conversion


I am using .net membership, The membership save the userid in hash format. I want to write a function that will convert this long hash user id into integer , and then convert it back to the same hash user id?

Any help would be really appreciated.

Pass Checkboxlist control multiple selected values to SQL table



I wanted to know if it is possible to pass multiple selected values from Checkboxlist to SQL table so each selections goes into separate row in the table.

I tried it using the following code (to pass ShowDate value) but it enters value only if I make one selection. It gives me an error message if I make two selections and try to pass it to SQL.


string showdate = string.Empty;

foreach (ListItem li in BirmShowDates.Items)
            if (li.Selected)
                showdate += li.Value;


            string sql = "INSERT INTO [BShow] ([Single], [UserId], [ShowDate], [Half]) VALUES (@Single, @UserId, @ShowDate, @Half) SELECT [Single], [UserId],  [ShowDate], [Half] FROM [BShow] WHERE [BShow].[ShowDate] = [BShow].[ShowDate]";

            SqlCommand cmd = new SqlCommand(sql, conn);

cmd.Parameters.AddWithValue("@ShowDate", showdate.ToString());


Thank you.

Get selected date value from DropDownList control and pass it to SQL table



This must be something not very difficult but I am pretty new in C# and have a problem to resolve.

I have tree dropdownlist controls. One of the control values are dates. When client selects all three drop downs then I am passing values to SQL table. Everything works but one. Date value shows 1900-01-01 instead of selected value in SQL table. I am not passing date value correctly but can't figure out how to do it.

Following is a code:

                            <asp:DropDownList ID="ddlLocation" runat="server" AutoPostBack="True" 
                                DataSourceID="SqlDataSource3" DataTextField="ShowLocation" 
                            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:myconnection%>" 
                                SelectCommand="SELECT * FROM [ShowLocation]"></asp:SqlDataSource>

T-SQL: is it possible to pass a table as parameter?


Can a table be passed as parameter to a T-SQL procedure or function?

One can define a temporary table within a procedure, and the system then manages its lifetime, keeps it separate from other instances executing the same procedure, etc: -

    CREATE PROCEDURE dbo.name (@Parameter1, @Parameter2)
        DECLARE @name TABLE
             (column list)

Perfect: but I need to be able to have another [recursive] procedure process this table.  How do I make it available to the second procedure?   If I write
    EXEC procedure @Name

an error message "Must declare the variable '@Name'" is produced.  Within the 2nd procedure, an attempt to name a table within the parameter list results in another error message, "Incorrect syntax near the keyword 'TABLE'".  

 If I can't pass it as argument/parameter, then how do you process a temporary table in another procedure?  Do I pass a cursor to it?  Or is it quite impossible?

Regards, Robert Barnes.


Can I have 3 different tables in a report? And, can I pass 3 temp table to SSRS as source for these

I'm using BI 2008 and sql 2005 and 2008.  Is there an example to show me?  Thanks.

How to pass paramaetrs to a sclar value function from a table output

HI all i am new using this scalar valued UDF,i had a requirement where i get an output of around 5 rows with 6 columns , and i have a sclar Function where i need to send parameters from above table and have to hold the output in to varible and have to display it , so for 5 rows i have to gert 5 outputs , can any one guide me how to do it ,i googled about it but i am unable to follow it ,please help me out let me know if am not clear with the Question.

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Insert value using Table Value Functions

a real gem in Sql Server 2008. mostly people still using Stored procedure may be they shifted to SQL Server but they are not using TVF right now.

Using jQuery to Filter Table Rows

The project is using the .net GridView control, so I had limited control over the output HTML code. Still, I think this code can work for most tables. One thing to notice: you should use the class "filterable" on your table or on one of its parents for the code to work.
First, we need a text box:

RadioButton Groups, Table Rows And NamingContainers in asp.net

The RadioButtonList. Very handy for inviting users to select just one item from a list although because of the screen real estate it takes up, used less and less in favour of the DropDownList. In plain HTML, the browser knows to enforce the unique selected value amongst a list of radio buttons because they all have the same value for their name attributes.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend