I want to connect MONGO DB to my VB Application i am making. I installed the essentiaal drivers, my MongoDB Server is running perfect. I can access it using MongoVUE but connection via VB somehow does not work
Imports MongoDB.Driver
Imports MongoDB.Driver.Linq
Imports MongoDB.Driver.Builders
Imports MongoDB.Bson
Public Class frmMongoDB
'<ObsoleteAttribute("Use MongoClient, GetServer and GetDatabase instead.")>
Private Sub frmMongoDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim server As MongoServer
Dim db As MongoDatabase
Dim coll As MongoCollection
server = MongoServer.Create("mongodb://localhost:27017")
db = server("db1")
coll = db("table1")
The line called server gets underlined and says " Public Shared function create as (connectionString as MongoDB.Driver.Mongo Server obsolete, Use MongoClient.GetServer instead"
I've tried Dim server As MongoServer = MongoServer.Create("mongodb://localhost")
But dosen't work either. Please help.
It mirrors the C# instructions .
Imports MongoDB.Driver
Sub Main()
Dim client As MongoClient
Dim server As MongoServer
Dim db As MongoDatabase
Dim col1 As MongoCollection
client = New MongoClient("mongodb://localhost")
server = client.GetServer()
db = server.GetDatabase("db1")
col1 = db.GetCollection("collection_one")
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.