Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 6th, 2006, 02:59 AM
dhaval229 dhaval229 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 9 dhaval229 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 7 sec
Reputation Power: 0
Thumbs up How i can connect access with vb?

hello friends,
i want to know how to connect with access using vb?

thanks in advance

Reply With Quote
  #2  
Old March 6th, 2006, 11:01 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
Pretty much in the same way that you do with ASP - but you just need to be more explicit when you declare stuff. Here's the basics...

Code:
Dim DBC As ADODB.Connection 'Connection to ADODB
Dim DSNtemp As String
Dim strSQL As String
Dim RS As ADODB.Recordset

Set DBC = New ADODB.Connection
Set RS = New ADODB.Recordset

DSNtemp = "Provider=MSDASQL;"
DSNtemp = DSNtemp & "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp = DSNtemp & "DBQ=C:\DataBase.mdb;"

DBC.Open DSNtemp
DBC.CursorLocation = adUseClient

strSQL = "SELECT ExampleField FROM tblExample;"
RS.Open strSQL, DBC, 2, 3

    If RS.EOF = False Then
    msgbox RS("ExampleField ")
    Else
    msgbox "Nothing There!"
    End If
Comments on this post
Shadow Wizard agrees: nice!
__________________
LozWare Website Directory

Whooo! Free submissions, no recip needed. I'm a nice guy

Reply With Quote
  #3  
Old March 6th, 2006, 03:39 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
You should use the newer Jet OLEDB database drivers, you can find examples at www.able-consulting.com

The MSDASQL driver is, I think, being phased out by MS, and using the older ODBC drivers is more prone to problems.

Also you need to add a reference in your VB project to ADO.

VB6 has a whole lot of databound controls, you can do all the database connections using controls rather than code if you prefer. Refer to the VB documentation.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #4  
Old March 6th, 2006, 05:18 PM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
I agreed with the first 2 things you said Doug - but not the third! The controls SUCK! Its a lot better to use the code - so much more adaptable.

Reply With Quote
  #5  
Old March 6th, 2006, 10:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
Quote:
Originally Posted by LozWare
I agreed with the first 2 things you said Doug - but not the third! The controls SUCK! Its a lot better to use the code - so much more adaptable.

Everyone is entitled to an opinion, right or wrong.

Reply With Quote
  #6  
Old March 7th, 2006, 12:24 AM
dhaval229 dhaval229 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 9 dhaval229 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 7 sec
Reputation Power: 0
thank you for sending me code.
its working.

thanks again

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > How i can connect access with vb?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT