我想得到最大值。但它不起作用。
drqry = "SELECT max(num) FROM tbCVinfo WHERE cvabbrv LIKE '%" & abbrv & "%' and `year` LIKE '%" & year & "%'"
'drqry = "SELECT max(cvno) FROM tbCVinfo WHERE cvno LIKE '%" & cvstr & "%'"
cmd2.CommandText = drqry
cmd2.Connection = con
dr = cmd2.ExecuteReader
Dim result As String = ""
If dr.Read() Then
dr.Close()
cv = Convert.ToInt32(cmd2.ExecuteScalar()) ''''i am having an error in this part. it says "Object cannot be cast from DBNull to other types." upon checking all datas in the database, I don't have null values
cv = cv + 1
If cv >= 0 And cv <= 9 Then
result = "000" & cv
2条答案
按热度按时间r8xiu3jd1#
这是我的密码。是的,它现在正在运行。非常感谢你的帮助。
5fjcxozz2#
如果您试图获取最大值,则第一个查询应该是: