Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 The multi-part identifier could not be bound.

Author  Topic 

seba
Starting Member

3 Posts

Posted - 2009-02-10 : 10:22:46
Hello.

I'm trying to get some data from sql server using my C# application. During data executing i get 4104 error: "multi-part identifier could not be bound" for every column in where part of sql. I'm using named parameters, bellow is full example of the problem in pure T-SQL.

declare @id int;
set @id = 0;
declare @OrgId int;
set @OrgId = 0;
declare @CatId int;
set @CatId = 0;
declare @ReqId int;
set @ReqId = 0;
declare @ResId int;
set @ResId = 0;
declare @StatId int;
set @StatId = 0;
declare @TeamId int;
set @TeamId = 0;
select
Q.Id,
Q.Subject,
Q.CategoryName,
Q.RequesterName,
Q.ResponsibleName,
Q.StatusName,
Q.Attachement,
Q.DueDate
from
QV_Queries Q
where (Q.Id = @Id or 0 = @Id)
and (O.OrgazniationId = @OrgId or 0 = @OrgId)
and (C.Id = @CatId or 0 = @CatId)
and (Req.PersonId = @ReqId or 0 = @ReqId)
and (Res.PersonId = @ResId or 0 = @ResId)
and (S.Id = @StatId or 0 = @StatId)
and (T.Team_ID = @TeamId or 0 = @TeamId)

here is the log from management studio:

Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "O.OrgazniationId" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "O.OrgazniationId" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "C.Id" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "Req.PersonId" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "Res.PersonId" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "S.Id" could not be bound.
Msg 4104, Level 16, State 1, Line 15
The multi-part identifier "T.TeamId" could not be bound.

So ... how can I use named parametes to do not duplicate everty parameter value (twice using one parameter value) ? Any other smart idea how to get the same result using another sql query ?

thanx for any help,
Seba

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 10:28:28
you dont have C,T,O,... in query. you need to either includes tables that represent them or replace all alises with Q (if it contain all columns)
Go to Top of Page

seba
Starting Member

3 Posts

Posted - 2009-02-10 : 10:30:57
OK, I propably know the bug. Sorry for the (stuppid) question.

Seba.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 10:32:47
no problem
Go to Top of Page

seba
Starting Member

3 Posts

Posted - 2009-02-10 : 10:37:32
quote:
Originally posted by visakh16

you dont have C,T,O,... in query ...



yes, I defined the View to have easy access to some search functionallity, but in query I'm still using tables (C,T,O, etc.)

thanx for fast response.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 10:38:30
replace them with view alias
Go to Top of Page
   

- Advertisement -