0

我正在尝试创建如下代码并错误提示“对象引用未设置为对象的实例”。

Public Shared Function bGetStaffCode(ByVal strUserName As String, ByVal conn As SqlConnection, ByRef strErr As String) As Boolean
    ' TODO: NotImplemented statement: ICSharpCode.SharpRefactory.Parser.AST.VB.OnErrorStatement
    Try

        'Dim bStaffCode As Boolean
        Dim strSQL As String = "select count(*) from portal_BillFinderAccess  where loginID = 'Elvis Tan '"

        Dim myCommand As New SqlCommand
        myCommand.Connection = conn
        myCommand.CommandText = strSQL

        'If CInt(myCommand.ExecuteScalar) = 0 Then

        Dim myDA As New SqlDataAdapter(strSQL, conn)
        Dim myDS As New DataSet
        myDA.Fill(myDS, "count")
        If myDS.Tables(0).Rows(0).Item(0).ToString = "0" Then
            MessageBox.Show("You are not authorized to use this application!")
            Return False
        Else
            Return True

        End If

    Catch err As Configuration.ConfigurationException
        MessageBox.Show(err.Message)
    Finally
    End Try


End Function`
4

0 回答 0