将vb6转换为vb.net时,Statment不是有效的名称空间

时间:2016-01-21 12:49:01

标签: vb.net vb6-migration

Public Function fnGetNextMaxNo(ByVal strFieldName As String) As Integer

    fnGetNextMaxNo = 0
    Dim adoRs As VbToRecordSet
    Dim strSql As String = ""
    Try
        fnGetNextMaxNo = 1

        strSql = "select max(" + strFieldName + ") from " + strTableName
        mstrLastExecutedSql = strSql
        adoRs.Open(strSql, adoconDb)
        If Not adoRs.EOF Then
            If Not IsDBNull(adoRs.Fields(0).Value) Then
                fnGetNextMaxNo = Convert.toDouble(adoRs.Fields(0).Value) + 1
            End If
        End If

        adoRs.Close()
        Exit Function

我正在尝试将vb6转换为vb.net,上面的代码第一行显示错误,该语句在名称空间中无效...请帮帮我

1 个答案:

答案 0 :(得分:0)

只需替换

Dim adoRs As VbToRecordSet

 Dim adoRs As adodb.RecordSet