Asp.net database created at for memebership logan

Last post 08-01-2007 12:02 AM by erickywong. 3 replies.

Sort Posts:

  • Asp.net database created at for memebership logan

    07-28-2007, 6:45 AM
    • Loading...
    • aammiz
    • Joined on 08-10-2004, 9:02 PM
    • Posts 268

    If I am developing a website  where I have customer database that i created.  Customer has his Unique ID for customer Table.

    Also when i am using the memebership of Visual Stuido , there it creates a database as well.

    Now when a user comes and enther his data to be a memember. He get his id and password.

    So now he can enter in the site.

    When a user enter a web site he is just going to enter his id and passward.

    Now how I am going to relate that user with the Customer Database. ?? which is different then the database that created by the asp.net. ???

    learning.. : )
    Filed under:
  • Re: Asp.net database created at for memebership logan

    07-30-2007, 2:40 AM
    Answer
    • Loading...
    • erickywong
    • Joined on 01-11-2007, 5:11 AM
    • Posts 74

    Hi Aammiz,

    If I undertand your question correctly, what you need to do is just to create an extra table to tied Customer and aspnet_Membership table together. The new table should consists at least:-

    Id (for simplicity you can use auto-number for this column),

    UserId (datatype should similar as UserId column on aspnet_Membership, uniqueidentifier) as foreign key to link to aspnet_Membership table, and

    CustId (datatype should similar as CustId on your Customer table) foreign key to link to your Customer table.

    When a new user created, his login Id and Password and other information (email, role and etc) that is necessary for ASP.NET membership to function will be stored in aspnet_<tablename> tables, while those extra information (address, dob, contact no. and etc) that you require from the customer when they sign up for membership on your website will be stored in your Customer table.

    I am not quite sure if you have 2 tables in 2 different databases or 2 tables in 1 database, as your reference to Customer is sometimes as a table and sometimes as a database. But, FYI, how I do it is, all the ASP.NET membership tables are on the same database as my application database. So as long as the extra table exists, there shouldn't be any issues to relate your application tables and ASP.NET membership tables.

    Alternatively, you just need to use the UserId (replace CustId with UserId) as the unique Id for your Customer table to link both the tables together, by doing it this way the relationship between tables are much simpler, instead of 3 tables you just have 2 tables.

    Cheers,

    Eric

  • Re: Asp.net database created at for memebership logan

    07-31-2007, 9:53 AM
    Answer
    • Loading...
    • aammiz
    • Joined on 08-10-2004, 9:02 PM
    • Posts 268

    sorry for not making it clear.

    But you gave me some thoughs. I am going to write it down the idea you are giving.

    Your idea is to have one database,

    So when we use the Asp.net 2.0 Membership and Role services, it creates a database for us.

    And when I need to have a database for my customer use. Instead of creating a new database add tables into ASPNet_DB.mdf  (asp.net database which was created by default).

    And place another table their to link them together.

    So Am I right??

    -----------------------------------

    As i said i might have been wrong the way i was thinking , the question i asked was:

    if you have that aspnet-DB.mdf  database and you have another database where you are storing the infomation of your cutomers. How would i link to those two database. Meaning, how could I incorporate the CustmerTable in my database and memebership table in the ASPNet_DB.mdf database.

     

    : )

    learning.. : )
  • Re: Asp.net database created at for memebership logan

    08-01-2007, 12:02 AM
    Answer
    • Loading...
    • erickywong
    • Joined on 01-11-2007, 5:11 AM
    • Posts 74

    Hello aammiz,

    You are almost correct. The aspnetdb is the database created by default when you install the membership provider without specifying the database you want to install it into. So in this case you do not add in new tables to it (aspnetdb), instead you specify the database when you install the membership provider.

    Run command below on your command prompt...

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S  <server>  -U <username> -P <password> -d <database> -A m -A r

    <server> is the  SQL server instance where your database is, e.g. ComputerName/SQLEXPRESS, if you are using SQLEXPRESS

    <username> and <password> is the username and password that is use to authenticate connection to your database

    <database> is your database name, the name of the database for your application

    m and r represents support for features that will be installed to your database where m is for Membership and r is for Role manager

    Example: 

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S ERICCOMPUTER\SQLEXPRESS  -U sa -P sa -d AccountSystem -A m -A r

    After running the command successfully (it will be indicated on the command prompt by the word Finished), now if you check on your database you will notice that few new tables with name starting with aspnet_ will be created. E.g. aspnet_Membership, aspnet_Roles, aspnet_Users and etc.

    Try it out.

    Cheers,

    Eric

Page 1 of 1 (4 items)