1

此代码在 VS 2010 和 2012 中完美运行。

Dim cmdText As String = "select * from master.dbo.sysdatabases where name=N'" & database & "'"
Dim bRet As Boolean = False
Using sqlConnection As SqlConnection = New SqlConnection(connString)
    Try
        sqlConnection.Open()
        Using sqlCmd As SqlCommand = New SqlCommand(cmdText, sqlConnection)
            Using reader As SqlDataReader = sqlCmd.ExecuteReader
                bRet = reader.FieldCount > 1
                reader.Close()
            End Using
        End Using
    Catch ex As SqlException
        MsgBox("Error Trying to Connect to database " & database & vbNewLine & ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
    Finally
        sqlConnection.Close()
    End Try
End Using

但是当我在 2013 年运行它时,这是我在 sqlConnection.Open() 命令中遇到的错误:-

System.Transactions.dll 中出现“System.ExecutionEngineException”类型的未处理异常

如果有这个异常的处理程序,程序可以安全地继续。

我已经找到并尝试了http://connect.microsoft.com/VisualStudio/feedback/details/791339/fatalexecutionengineerror
但无济于事
有没有人有任何指针?我被困住了。

4

0 回答 0