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("插入成功!");

  • 相关阅读:
    单片机4*4按键数码管显示0-9
    netbeans设置语言
    单片机中断的应用
    Linux 命令总结
    vc6.0快捷键大全
    怎么使PUTTY一直连接
    mysql alter 效率
    treeview
    Gitbook
    linux 进程监控软件 supervisor
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2523969.html
Copyright © 2011-2022 走看看