我正在将 VB2005 Web 应用程序移植到 VB2008,但在编译时遇到了问题。
问题是在我尝试编译项目时引起的,我得到这个错误就行了:
If m Is DBNull.Value...
错误:
'Is' operator does not accept operands of type 'Integer'.
Operands must be reference or nullable types.
代码:
Public Shared Function getNextID(ByVal t As String, ByVal f As String)
Dim m = 0
Dim c As New Data.SqlClient.SqlConnection
c = getConn()
c.Open()
Dim s As String
s = "SELECT MAX(" & f & ")AS max FROM " & t
Dim q As New Data.SqlClient.SqlCommand(s, c)
Dim r = q.EmecuteReader
While r.Read
m = r.GetValue(0)
End While
If m Is DBNull.Value Then
m = 1
Else
m += 1
End If
r = Nothing
q = Nothing
c.Close()
c = Nothing
Return m
End Function
有没有办法让这个功能在不改变的情况下运行?如果没有,我将如何解决它?