1

Currently i have 2 tables, which is user_table and application_table. The main table is application_table, but i need some information to display which only can find in user_table.

CREATE TABLE [dbo].[Application_Table] (
    [Id]               INT           IDENTITY (0, 1) NOT NULL,
    [Name]             VARCHAR (50)  NULL,
    [Date]             DATE          NULL,
    [Vehicle]          VARCHAR (50)  NULL,
    [DestinationFrom]  VARCHAR (50)  NULL,
    [DestinationTo]    VARCHAR (50)  NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);

here is the second table:

CREATE TABLE [dbo].[User_table] (
    [Name]            VARCHAR (50) NOT NULL,
    [Email]           VARCHAR (50) NULL,
    [Password]        VARCHAR (50) NULL,
    [Department]      VARCHAR (50) NULL,
    CONSTRAINT [PK_User_table] PRIMARY KEY CLUSTERED ([Name] ASC)
);

I need to display all information from application_table and some information such as email, department from user_table based on Name in application_table in gridview.

Is that any simple way to do it? I am quite new in asp net and c#, please guide me as i am a slow learner.

user990423
  • 1,397
  • 2
  • 12
  • 32
Wen21
  • 93
  • 8
  • 1
    Is the `Name` column in the `Application_Table` the user's name in the `User_Table`? If so, in your SQL query, you can just `join` the two tables in order to get information from both: `select * from application_table inner join user_table ON user_table.Name = application_table.Name` Does that make sense? – Mark Oct 22 '15 at 00:57
  • Yes, they are same. Where should i put the `select * from application_table inner join user_table ON user_table.Name = application_table.Name`? sorry, i am very new in this... – Wen21 Oct 22 '15 at 01:38
  • Dont you have some kind of `SqlDataAdapter` that you use? Check this out for more help: http://stackoverflow.com/questions/18113278/populate-a-datagridview-with-sql-query-results – Mark Oct 22 '15 at 01:40
  • Mark, i use visual basic and i found the place for the datasource that you mentioned earlier. I am able to bind with the data after i join the table... Thanks a lot... – Wen21 Oct 22 '15 at 01:53
  • The two table above is it in the same database ? Because your question is not clear due to 2 database or 2 table? – Nic Oct 22 '15 at 01:54
  • Great, perhaps update you question with the answer to help out other later on? – Mark Oct 22 '15 at 02:04

1 Answers1

0

You could achieve that using a multi level grid. Refer to this for details ASP Multi Level Grid

BTW you should add a foreign key to your second table.

Moe
  • 1,599
  • 11
  • 16