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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.