0

Hi so I have three database tables, aspnet_Membership, aspnet_Users and tableUsers. These tables keep record off users on the system and what I am trying to do is to create a gridiview that lists the users that are locked out. The columns I would like is userID, customer name, customer contact name and an unlock button. I have this all in place but there must be a problem with my SQL as the gridview columns customer name and customer contact name are blank. The SQL code I have is

select aspnet_Membership.UserId,IsLockedOut,UserName,CustomerName,CustomerContactName
 from dbo.aspnet_Membership
 left join dbo.aspnet_Users on aspnet_Users.UserId = aspnet_Membership.UserId
 left join dbo.tableCustomer on CustomerCode = UserName
  where IsLockedOut = 1

The columns included in the tables are:
aspnet_Membership - this is the table provided to store membership data.
aspnet_Users - again the table provided.
tableCustomers - This table contains the CustomerCode, CustomerName and CustomerContactName.

Any idea's of why it isn't displaying the customer name and contact name? guessing there is something wrong with the code.

2
Contributors
1
Reply
16
Views
4 Years
Discussion Span
Last Post by urtrivedi
0

try to join with userid insteaad username

on CustomerCode = aspnet_Users.UserId

select aspnet_Membership.UserId,IsLockedOut,UserName,tableCustomer.CustomerName,tableCustomer.CustomerContactName
 from dbo.aspnet_Membership
 left join dbo.aspnet_Users on aspnet_Users.UserId = aspnet_Membership.UserId
 left join dbo.tableCustomer on CustomerCode = aspnet_Users.UserId
  where IsLockedOut = 1
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.