Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In grid view in more than one table values should bind in GridView1..


1.fileInfo

SQL
CREATE TABLE [dbo].[fileInfo](
    [fileId] [bigint] IDENTITY(1,1) NOT NULL,
    [userId] [bigint] NULL,
    [fileName] [nvarchar](50) NOT NULL,
    [fileType] [nvarchar](50) NOT NULL,
    [fileSize] [nvarchar](100) NOT NULL,
    [filePath] [nvarchar](200) NOT NULL,
    [createdOn] [datetime] NULL,
    [statusId] [bigint] NULL,
    [lastModifiedOn] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
    [fileId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO



2.status
SQL
CREATE TABLE [dbo].[status](
    [statusId] [bigint] IDENTITY(1,1) NOT NULL,
    [statusName] [nvarchar](30) NOT NULL,
    [statusColor] [nvarchar](10) NOT NULL,
    [active] [bit] NULL,
    [createdOn] [datetime] NULL,
    [modifiedOn] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
    [statusId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO



3.userInfo
SQL
CREATE TABLE [dbo].[userInfo](
    [userId] [bigint] IDENTITY(1,1) NOT NULL,
    [email] [nvarchar](30) NOT NULL,
    [password] [nvarchar](20) NOT NULL,
    [firstName] [nvarchar](50) NULL,
    [lastName] [nvarchar](50) NULL,
    [activationKey] [nvarchar](800) NULL,
    [active] [bit] NULL,
    [createdOn] [datetime] NULL,
    [modifiedOn] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
    [userId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
    [email] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO


i want to display: fileName, FileType, fileSize, filePath, CreatedOn from fileInfo Table and statusname from status Table

I try it like this
SQL
select fileName, fileType, fileSize, filepath,createdOn,statusName from status inner join fileInfo where userId=(select userId from userInfo where email)


please say correct solution Friends!

Advance Thanks Friends!
Posted
Updated 6-Apr-13 3:07am
v2

SQL
select f.fileName,f.fileType,f.fileSize,f.filepath,f.createdOn,s.statusName 
 from fileInfo As f left join status As s on f.statusId=s.statusId 
 where userId=(select userId from userInfo where email) 
 
Share this answer
 
Try this query. Where @emailUser is the variable of email of the user.

SQL
select  fileInfo.fileName, fileInfo.fileType, fileInfo.fileSize,
        fileInfo.filePath, fileInfo.createdOn, status.statusName
from fileInfo inner join status on fileInfo.statusId = status.statusId
              inner join userInfo on fileInfo.userId = userInfo.userId
where userInfo.email = @emailUser
 
Share this answer
 
Comments
Rekhash 8-Apr-13 2:40am    
@Member 8136496 Thanks Friend
Try this query. Where @emailUser is the variable of email of the user.

SQL
select  fileInfo.fileName, fileInfo.fileType, fileInfo.fileSize,
        fileInfo.filePath, fileInfo.createdOn, status.statusName
from fileInfo inner join status on fileInfo.statusId = status.statusId
              inner join userInfo on fileInfo.userId = userInfo.userId
where userInfo.email = @emailUser
 
Share this answer
 
SQL
select f.fileName,f.fileType,f.fileSize,f.filepath,f.createdOn,s.statusName 
 from fileInfo As f left join status As s on f.statusId=s.statusId 
 where userId=(select userId from userInfo where email) 
 
Share this answer
 
Comments
Rekhash 8-Apr-13 2:41am    
@Anil Limbani Thanks Friend...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900