Hello Friends,
I am learning VB.Net (Visual Studios 2005) and using MS Access as backend database. pls someone tell me how to connect VB.net to MS Access.

EASY :)

First, before defining the class write imports system.data.oledb

Second, inside your sub, you need to define a connection to the data base (for ex. Dim con as new oledbconnection)
then write the following:

con.ConnectionString = "provider=microsoft.jet.oledb.4.0; data source=C:\DB.mdb"

ofcourse instead of C:\DB.mdb you will write the drive where you saved the db and its name

then open your connection (con.open())


then define the command (dim cmcontact as new oledbcommand)
inside the command you will write the sql statement like insert to insert to the db also update or select

write the following 2 statements:

cmcontact.Connection = con
cmcontact.ExecuteNonQuery()
con.Close()


that is it my friend
Happy Coding

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.