zoukankan      html  css  js  c++  java
  • C# , mongodb ,study

    //MongoDB服务器连接串

    string connectionString = ConfigurationManager.ConnectionStrings["concString"].ToString();
    MongoServer server = MongoServer.Create(connectionString);

    //连接到mydb数据库
    MongoDatabase db = server.GetDatabase("mydb");

    //连接到testzj集合
    MongoCollection collection = db.GetCollection("testzj");

    //创建对象stu1
    BsonDocument stu1 = new BsonDocument
    {
    {"total_variable_characters2","0018"},
    {"fixed_weather_station_usaf_master_station_catalog_identifier2","128970"},
    {"fixed_weather_station_ncdc_wban_identifier2","256542"}
    };

    //创建对象stu2

    BsonDocument stu2 = new BsonDocument();

    stu2.Add("abc", 2);
    stu2.Add("efg", "hello world");

    //将对象stu1 and stu2放到集合students中
    collection.Insert(stu1);

    collection.Insert(stu2);

    MessageBox.Show("插入成功!");

  • 相关阅读:
    16.14
    16.13
    JAVA JLabel自定义子类无法显示
    16.12
    16.11
    css实现垂直居中
    HTML5学习笔记
    HTML、Css中插入图片的一些问题
    MySQL的if函数
    java实现将汉字转为首字母、拼音
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2523969.html
Copyright © 2011-2022 走看看