MongoDB Query in VB.Net -
i can not vb.net connect mongodb replicaset - throws exceptions
dim mongo mongodbclient dim mgdb mongodatabase dim mgcol mongocollection(of bob) public class bob public property id objectid public property name string end class sub main() try mongo = new mongoclient("mongodb://ip:port,ip:port,ip:port/?replicaset=bob") mgdb = mongo.getdatabase("test") mscol = mgdb.collection(of bob)("test.me") mgdb.getcollection("test.me").find(mongodb.driver.builders.query.exists("id")) catch ex exception console.writeline(ex) end try end sub
i don't know how i'm supposed query via vb .net?
i got work
dim _client imongoclient dim _db imongodatabase sub main() system.console.writeline("hi, bob!!") try _client = new mongoclient("mongodb://mongoone:27020,mongotwo:27021,mongothree:27020/?replicaset=bob") _db = _client.getdatabase("test") dim mgcol = _db.getcollection(of bob)("test.me") dim mybob bob mybob = new bob mybob.name = "sam6" mybob.id = objectid.generatenewid 'mgcol.insertone(mybob) getsomedata().wait() 'getdatabyfilterextists().wait() 'getmetacardspectrum().wait() getmetacardspectrumobj().wait() catch ex exception console.writeline(ex) end try end sub
Comments
Post a Comment