在vb.net中存储在变量中的最小日期 [英] Min Date to store in Variable in vb.net
本文介绍了在vb.net中存储在变量中的最小日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我使用sql qry从数据库中获取了最小日期,并且当我尝试将min.date存储在一个变量中时,它出现了错误,请PlZ帮助我.用于以下编码.
Hi Guys,
I got Minimum date from database using sql qry, And when i try to store that min.date in one variable, its getting error, PlZ help me. for below coding.
Dim Min_Date As Date
If SqlCon.State = ConnectionState.Closed Then
SqlCon.Open()
End If
qry = "Select MIN(Quote_date) from tbl_quotes"
SqlCmd = New SqlCommand(qry, SqlCon)
SqlReader = SqlCmd.ExecuteReader
If SqlReader.HasRows Then
While SqlReader.Read
Min_Date = SqlReader("Quote_date") -----> Error Line(Need Help here)
End While
End If
SqlReader.Close()
SqlCon.Close()
预先感谢
由
Shajatha
Advance Thanks
By
Shajatha
推荐答案
1)如果返回单个值,则无需循环-您只需检查
1) If you are returning a single value, you don''t need to loop - you can just check
If SqlRead.Read Then
并继续.
2)如果使用SQL表达式,则需要给列命名:
and continue.
2) You need to give the column a name if you use an SQL Expression:
qry = "Select MIN(Quote_date) AS MinDate from tbl_quotes"
Min_Date = SqlReader("MinDate")
这篇关于在vb.net中存储在变量中的最小日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文