开发者

sql query error [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

please correct me with the sql query

giving error mentioned below y so please correct me on this

Msg 137, Level 15, State 2, Line 1 Must declare the scalar variable "@courseId".

@"SELECT * FROM [tbl_students] WHERE course_id=@courseId AND branch_id IN("+branchId+@") 
                AND (@passoutYear is null OR passing_year>=@passoutYear) 
               AND  (@currentBacklog is null OR current_backlog<=@currentBacklog)
AND  gender=@sex AND (@eGap is null OR gapin_education<=@egap)
AND  (@firstYrPercent is null OR first_year_percent>=@firstYrPercent
AND  (@secondYrpercent is null OR second_year_percent>=@secondYrPercent)
AND  (@thirdYrPercent is null OR third_year_percent>=@thirdYrPercent)
AND  (@finalYrpercent is null OR final_year_percent>=@finalYrpercent)
AND  (@currentDegreePercentage is null OR current_degree_percent>=@currentDegreePercentage)
AND  (@highSchoolPercentage is null OR highschool_percentage>=@highSchoolPercentage)
AND  (@higherSchoolPercentage is null OR ssc_percentage>=@higherSchoolPercentage)
AND  (@graduationPercent i开发者_如何学Gos null OR graduation_percentage>=@graduationPercentage)
AND  (@diplomaPercentage is null OR diploma_percentage>=@diplomaPercenage)
AND  (@noOfAtkt is null OR number_of_ATKT<=@noOfAtkt)
AND  (@date is null OR DOB>=@date)"


You have either:

  • Not declared your variable @courseId within the SQL query
  • Not declared a parameter to the Stored Procedure


That just means you forgot to create an SqlParameter value for @courseId for your command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜