如何在VB中将SqlDbType datetime转换为字符串

时间:2014-09-25 16:59:45

标签: vb.net datetime sqldbtype

我想将日期列显示在存储过程返回的文本框中。该错误显示列名称。 谢谢你的帮助!

SQL存储过程:

SELECT MAX(NrTimesUpdated) AS NrTimesUpdated,   
       CONVERT(varchar(20),MAX(DateModified),101) AS DateEntered
FROM   Credentials
WHERE ID = @ID
END

VB代码:

Dim cmd As New SqlClient.SqlCommand
cmd = New SqlCommand("get_credentials", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@ID", SqlDbType.Int).Value = lblID.Text
Dim rdr = cmd.ExecuteReader
If rdr.Read Then
   lblDate.Text = rdr("DateEntered").ToString().Trim()
End If
rdr.Close()

0 个答案:

没有答案