G
Gerry Viator
Hi all,
Trying to just return a date, keep getting vb.net error on
"Dim DataReader As SqlDataReader = EusCmd.ExecuteReader()"
***VB.net
Private Function getLastDate() As DateTime
FunctionMainConnection()
Dim EusCmd As New SqlCommand("getlastdate", MainSQLConn)
MainSQLConn.Open()
Dim DataReader As SqlDataReader = EusCmd.ExecuteReader()
EusCmd.CommandType = CommandType.StoredProcedure
EusCmd.CommandTimeout = 20
EusCmd.Connection = MainSQLConn
EusCmd.Parameters.Add("@out", SqlDbType.DateTime) '
Output Parameter
EusCmd.Parameters("@out").Direction = ParameterDirection.Output
While DataReader.Read
getLastDate = DataReader.GetString(0)
End While
DataReader.Close()
MainSQLConn.Close()
End Function
**********SQL stored procedure
CREATE PROCEDURE getlastdate
@lastd datetime out
AS
set @lastd = (select CONVERT( CHAR(12), max(incrementDate),101) from
EusBatchIncrement)
GO
Thanks for your help
Gerry
Trying to just return a date, keep getting vb.net error on
"Dim DataReader As SqlDataReader = EusCmd.ExecuteReader()"
***VB.net
Private Function getLastDate() As DateTime
FunctionMainConnection()
Dim EusCmd As New SqlCommand("getlastdate", MainSQLConn)
MainSQLConn.Open()
Dim DataReader As SqlDataReader = EusCmd.ExecuteReader()
EusCmd.CommandType = CommandType.StoredProcedure
EusCmd.CommandTimeout = 20
EusCmd.Connection = MainSQLConn
EusCmd.Parameters.Add("@out", SqlDbType.DateTime) '
Output Parameter
EusCmd.Parameters("@out").Direction = ParameterDirection.Output
While DataReader.Read
getLastDate = DataReader.GetString(0)
End While
DataReader.Close()
MainSQLConn.Close()
End Function
**********SQL stored procedure
CREATE PROCEDURE getlastdate
@lastd datetime out
AS
set @lastd = (select CONVERT( CHAR(12), max(incrementDate),101) from
EusBatchIncrement)
GO
Thanks for your help
Gerry