none
How to change view cardsdatavalue without display error the multi-part identifier "dbo.cardreceived.year" could not be bound. ? RRS feed

  • Question

  • I work on app using csharp and SQL server 2014 database

    when check the problem problem i found 

    that table name exist before fields as following :


    SELECT     * from cardsdatavalue Where 1=1  and  dbo.CardReceived.Year = '2019' and  dbo.CardReceived.ReceivedDate >= '2019-01-01' and CardReceived.ReceivedDate <= '2019-04-16'



    the statement above will work if i removed table name cardrecieved from where statement on c sharp code

    but this will make me doing new change on c sharp code so that


    How to do changes on view to do this work from SQL server 2014 without
    change on c sharp code ?
    meaning i need to change view cardsdatavalue to make multi part error not display ?

    create view cardsdatavalue as SELECT        dbo.CardReceived.MemberCode, dbo.Members.SpecialCode, dbo.Members.Name, dbo.CardReceived.Year, dbo.CardReceived.ReceivedDate, 
                             dbo.CardReceived.Notes, dbo.CardReceived.CardType, dbo.CardType.CardAraType, dbo.CardType.CardLatType
    FROM            dbo.CardReceived LEFT OUTER JOIN
                             dbo.CardType ON dbo.CardReceived.CardType = dbo.CardType.CardTypeId LEFT OUTER JOIN
                             dbo.Members ON dbo.CardReceived.MemberCode = dbo.Members.MemberCode



    Tuesday, April 16, 2019 10:15 AM

Answers

  • Sorry, it is not possible to make the changes on the view to let the query in C sharp working since the SELECT statement is incorrect.

    A Fan of SSIS, SSRS and SSAS

    Tuesday, April 16, 2019 3:48 PM

All replies

  • Your view is okay, but the SELECT statement in C sharp code is not correct. You need to change it to 

    SELECT * 
    from cardsdatavalue 
    Where 1=1 and Year = '2019' and ReceivedDate >= '2019-01-01' and ReceivedDate <= '2019-04-16'


    A Fan of SSIS, SSRS and SSAS

    Tuesday, April 16, 2019 2:06 PM
  • thank you for reply 

    i know that answer 

    please leave all that above my question as following 
    i open new query sql server 2014 i write query as following
    SELECT * from cardsdatavalue Where 1=1 and dbo.CardReceived.Year = '2019' and dbo.CardReceived.ReceivedDate >= '2019-01-01' and CardReceived.ReceivedDate <= '2019-04-16'
    Are there are any way to get result of data without changing on where condition table name

    i need to change on view without change on where clause 

    are there are any thing can done on view to prevent that error from display please ? 

    Tuesday, April 16, 2019 2:39 PM
  • When you are creating a view, you are hiding the complexity. So dbo.CardReceived.Year, inside the view will be only "Year" column from outside. I am sorry there is nothing that can be done (AFAIK) to change view to make your c-sharp query in working! 

    Tuesday, April 16, 2019 2:48 PM
  • Sorry, it is not possible to make the changes on the view to let the query in C sharp working since the SELECT statement is incorrect.

    A Fan of SSIS, SSRS and SSAS

    Tuesday, April 16, 2019 3:48 PM