Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9375

Comment on: "primer/client.txt"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • primer
    • 0.25

    Description

      Hi, I'm supposed to use
      "protected static IMongoClient _client;
      protected static IMongoDatabase _database;

      _client = new MongoClient();
      _database = _client.GetDatabase("test");"

      Upon rebuilding my code, I'm getting "Invalid expression term 'protected'. How do i resolve this?

      my test code:

      using System;
      using System.Collections.Generic;
      using System.Globalization;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using MongoDB.Bson;
      using MongoDB.Driver;
       
      namespace CSharpMongo
      {
          class Program
          {
              static void Main(string[] args)
              {
                  #region Insert Data with C# Driver, https://docs.mongodb.com/getting-started/csharp/insert/
                      #region Prerequisites
                          //Follow the Connect to MongoDB step to connect to a running MongoDB instance and declare and define the variable _database to access the test database.
                          //Include the 3 using statements (as shown per the site mentioned above).
                          #region Connect to MongoDB
                              //Add the 2 using statements in your C# program.
                              //Now, connect:
                              protected static IMongoClient _client;
                              protected static IMongoDatabase _database;
       
                              _client = new MongoClient();
                              _database = _client.GetDatabase("test");
                              //To specify a different host and port for the mongod instance, see the MongoClient API page
       
       
                          #endregion
       
                      #endregion
                  #endregion
              }
          }
      }
      

      Thanks in advance for your help,
      Tien

      Attachments

        Activity

          People

            allison.moore@mongodb.com Allison Reinheimer Moore
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 10 weeks, 6 days ago