无法将类型为"System.Decimal"的对象转换为类型为"System.Data.SqlClient.SqlDataReader"

问题描述:



我正在犯错.

这是什么..

无法将类型为"System.Decimal"的对象转换为类型为"System.Data.SqlClient.SqlDataReader"."

代码在下面
--------------

Hi,

I am getting below erroe.

what is this..

"Unable to cast object of type ''System.Decimal'' to type ''System.Data.SqlClient.SqlDataReader''."

Code is below
--------------

Function FindLoad(ByVal WeekNo As Integer, ByVal year As Integer, ByVal Empid As Integer, ByVal ProjectCode As String) As Decimal
        Dim Conn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("MPP").ConnectionString)
        Dim Cmd As New System.Data.SqlClient.SqlCommand
        Dim Rdr As System.Data.SqlClient.SqlDataReader
        Dim Qry As String
        Qry = ""
        Conn.Open()
        Qry = "select isnull(val,0) as value from WeeklyLoad where WeekPeriod=" & WeekNo & " and YearPeriod =" & year & " and Emp_number =''" & Empid & "'' and ProjectCode =''" & ProjectCode & "'' "
        Cmd.Connection = Conn
        Cmd.CommandText = Qry
        Rdr = Cmd.ExecuteScalar
        If Rdr.HasRows Then
            While Rdr.Read
                FindLoad = Rdr("value")
            End While
        Else
            FindLoad = ""
        End If
        Rdr.Close()
        Conn.Close()
    End Function



什么是错误...?



what is the Error...?

Change
Rdr = Cmd.ExecuteScalar


Rdr = Cmd.ExecuteReader