944,124 Members | Top Members by Rank

Ad:
  • VB.NET Code Snippet
  • Views: 8379
  • VB.NET RSS
0

Connecting to access database

by on Sep 11th, 2006
Code for connecting to Microsoft Access databse, opening and closing connection
VB.NET Code Snippet (Toggle Plain Text)
  1. Dim cn As New OleDbConnection
  2. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Data.mdb;Persist Security Info=True"
  3. cn.Open()
  4. cn.Close()
Comments on this Code Snippet
Feb 24th, 2008
0

Re: Connecting to access database

hello sir. i tried that code but it doesn't work. it says that it's not defined. what should i do?
Newbie Poster
dengbadeng is offline Offline
1 posts
since Feb 2008
Jul 18th, 2008
0

Re: Connecting to access database

did you add a header to it ? add 'imports system.data.oledb' as the header and try
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 4th, 2011
0

Re: Connecting to access database

which dbr u using-- access 2003 or 2007 ??
the code is for 2003
for 2007 use
"Provider=Microsoft.ACE.OLEDB.11.0;Data Source=|DataDirectory|Data.ACCdb;Persist Security Info=FALSE"

N A MSGBOX
Newbie Poster
pocohontus is offline Offline
9 posts
since Nov 2008
Jun 5th, 2011
0

Re: Connecting to access database

'firs import
VB.NET Syntax (Toggle Plain Text)
  1. imports system.data.oledb
  2. Dim con As New OleDbConnection()
  3. con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=h:\MAINDB.mdb;"
  4. con.open
  5. statements
  6. con.close
Last edited by peter_budo; Aug 20th, 2011 at 4:13 am. Reason: Adding code tags
Light Poster
uv4u is offline Offline
47 posts
since Jan 2011
Message:
Previous Thread in VB.NET Forum Timeline: vb6 to vb.net
Next Thread in VB.NET Forum Timeline: How to fix resx error after changing file name





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC