A
ajaymehra
Hi,
Im using a calendar control and on the dayrender event - I call m
sub, which runs a query and gets a SUM value for each day. Below is th
code
----------------------------------------------------
Public Sub calhours_dayrender(ByVal s As Object, ByVal e A
DayRenderEventArgs)
Dim calCell As TableCell
Dim DayHours As String
Dim DayDate As Date
Dim Conn As SqlConnection = Ne
SqlConnection("Server=CHRI_01001; Initial Catalog=ELY3019; uid=mmapp
password=pwd")
DayDate = e.Day.Date
calCell = e.Cell
Dim sqlComm As SqlCommand
Dim sqlDR As SqlDataReader
Conn.Open()
sqlComm = New SqlCommand("Select Convert(int
Sum(Round(Hours,0))) as Hours From GetHoursForDays('10314', '"
DayDate & "', '" & DayDate & "')", Conn)
sqlDR = sqlComm.ExecuteScalar()
DayHours = CType(sqlDR("Hours"), String)
'DayHours = CType(sqlDR(0), String)
Conn.Close()
calCell.Controls.Add(New LiteralControl("<p><font color=whit
size=1>"))
calCell.Controls.Add(New LiteralControl(DayHours))
End Sub
----------------------------------------------------
I keep getting this error :
Specified cast is not valid.
Description: An unhandled exception occurred during the execution o
the current web request. Please review the stack trace for mor
information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is no
valid.
Source Error:
Line 54: sqlDR = sqlComm.ExecuteScalar()
Any ideas ??
ajaymehr
Im using a calendar control and on the dayrender event - I call m
sub, which runs a query and gets a SUM value for each day. Below is th
code
----------------------------------------------------
Public Sub calhours_dayrender(ByVal s As Object, ByVal e A
DayRenderEventArgs)
Dim calCell As TableCell
Dim DayHours As String
Dim DayDate As Date
Dim Conn As SqlConnection = Ne
SqlConnection("Server=CHRI_01001; Initial Catalog=ELY3019; uid=mmapp
password=pwd")
DayDate = e.Day.Date
calCell = e.Cell
Dim sqlComm As SqlCommand
Dim sqlDR As SqlDataReader
Conn.Open()
sqlComm = New SqlCommand("Select Convert(int
Sum(Round(Hours,0))) as Hours From GetHoursForDays('10314', '"
DayDate & "', '" & DayDate & "')", Conn)
sqlDR = sqlComm.ExecuteScalar()
DayHours = CType(sqlDR("Hours"), String)
'DayHours = CType(sqlDR(0), String)
Conn.Close()
calCell.Controls.Add(New LiteralControl("<p><font color=whit
size=1>"))
calCell.Controls.Add(New LiteralControl(DayHours))
End Sub
----------------------------------------------------
I keep getting this error :
Specified cast is not valid.
Description: An unhandled exception occurred during the execution o
the current web request. Please review the stack trace for mor
information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is no
valid.
Source Error:
Line 54: sqlDR = sqlComm.ExecuteScalar()
Any ideas ??
ajaymehr