954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need Help

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.

deepukng
Newbie Poster
18 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

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

q8_dreamy
Light Poster
38 posts since Apr 2008
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You