Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise Design Integration Forum ProjectWise api aaApi_SelectDocumentsByProp call fails with Error code:50045 No database connection is active at the moment
    • Sign In

    • State Not Answered
    • Replies 0 replies
    • Subscribers 60 subscribers
    • Views 949 views
    • Users 0 members are here
    • API
    • VBA
    • c#
    • ProjectWise Documents

    ProjectWise api aaApi_SelectDocumentsByProp call fails with Error code:50045 No database connection is active at the moment

    Senthil Kandasamy
    Offline Senthil Kandasamy over 4 years ago

    Hi,

    I am stuck with the below issue while using ProjectWise SDK for fetching documents. Any solution or pointers would be really helpful.

    I am fetching documents from a given project using aaApi_SelectDocumentsByProp method call. I then extract few details of documents and pass it to another function. The below code works fine in my machine, however, the same code fails in customer's machine and the log file gives following details : 

    "ProjectWise returned the following. No database connection is active at the moment.; No database connection is active at the moment.; Error code:50045"

    One of our customers is getting the below error while attempting to get document details. The same code works fine in development machine. 

    Can you please let me know if there is anything that could go wrong with the below code:

    int count = PwDotNet.aaApi_SelectDocumentsByProp(
                            (int)projectId,
                            0,
                            (int)PwDotNet.DOCUMENT_FILE_TYPE_Flags.AADMS_FTYPE_TEXT,
                            (int)PwDotNet.DOCUMENT_TYPE_FLAGS.AADMS_ITYPE,
                            applicationId,
                            0, null, null, null, null, 0, 0, 0, 0, null, 0, 0);
    
                if (count == -1)
                {
                    var error = GetLastErrorCompleteDetails();
                    throw new ArgumentNullException("Error selecting the documents: " + error);
                }
    
    
                var bufferSize = 512;
                var workingFile = new StringBuilder(bufferSize, bufferSize);
                var downloadedDocumentPath = string.Empty;
                var documentId = 0;
    
                for (int index = 0; index < count; index++)
                {
                    downloadedDocumentPath = string.Empty;
                    documentId = PwDotNet.aaApi_GetDocumentId(index);
    
                    if (documentId == 0)
                    {
                        // The execution fails here. The error description is
                        // No database connection is active at the moment.; No database connection is active at the moment.; Error code:50045
                        var error = GetLastErrorCompleteDetails();
                        
                        continue;
                    }
                    var documentObject = PwDotNet.aaApi_SelectDocument(projectId, (long) documentId);
    
                    string documentName = Marshal.PtrToStringUni(PwDotNet.aaApi_GetDocumentStringProperty(20, index));
                    int fileSize = PwDotNet.aaApi_GetDocumentNumericProperty(7, (int)documentId);
                    string lastModifiedTimeAsString = Marshal.PtrToStringUni(PwDotNet.aaApi_GetDocumentStringProperty(25, index));
                 }  

    • Sign in to reply
    • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies