does not have a corresponding column in the data reader with the same name

前端 未结 4 1233
清歌不尽
清歌不尽 2021-01-04 00:56

I have Table named tbl_search with columns : id(int), title(nvarchar100), result(ntext) and i want using SQL query, like

相关标签:
4条回答
  • 2021-01-04 01:07

    I did the following:

    1. Verified that the stored procedure was up-to-date (the "live" columns were updated).
    2. In EF, I removed, saved, then re-added the stored proc.
    3. Rebuilt and verified all of the types were mapped correctly (no errors).

    After doing the above, the error was gone.

    0 讨论(0)
  • 2021-01-04 01:12

    Please check the connection string in the web.config(Check if you are connected to correct domain).

    In my case - my database connection string in web.config was referring to QA and I was modifying in Dev database.

    0 讨论(0)
  • 2021-01-04 01:13

    Your SQL Statement only returns the title not the full entity.

    Change:

    Select top 1 title From tbl_search Where title=@title and id=@id 
    

    to:

    Select top 1 * From tbl_search Where title=@title and id=@id 
    
    0 讨论(0)
  • 2021-01-04 01:24

    I solved this issue because I had a '@StartDate' in my last select and asp.net could not read it and returned it as 'Column1', so I have solved this by assigning @StartDate to a variable which is good practice anyway.

    0 讨论(0)
提交回复
热议问题