Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADODB.Connection in vb 6.0

Posted on 2009-05-05
3
Medium Priority
?
2,825 Views
Last Modified: 2013-11-25
Hi

I have created a sample application in vb.6.0 in which I have created a button. On the button I am trying to fetch the data from access database.

Above the event I have declared

Public CNDB As New ADODB.Connection

But when I run the program I am getting error

Do I need to add any reference.
0
Comment
Question by:KaranGupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:Brian Withun
ID: 24311279
Read over this article from MS:

http://support.microsoft.com/kb/168336

   Private Sub cmdOpen_Click()
       Dim Conn1 As New adodb.Connection
       Dim Cmd1 As New adodb.Command
       Dim Errs1 As Errors
       Dim Rs1 As New adodb.Recordset
 
       Dim i As Integer
       Dim AccessConnect As String
 
       ' Error Handling Variables
       Dim errLoop As Error
       Dim strTmp As String
 
       AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _
                     "Dbq=nwind.mdb;" & _
                     "DefaultDir=C:\program files\devstudio\vb;" & _
                     "Uid=Admin;Pwd=;"
 
       '---------------------------
       ' Connection Object Methods
       '---------------------------
 
       On Error GoTo AdoError  ' Full Error Handling which traverses
                               ' Connection object
 
       ' Connection Open method #1:  Open via ConnectionString Property
       Conn1.ConnectionString = AccessConnect
       Conn1.Open

Open in new window

0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 2000 total points
ID: 24311280
Yes, you need to add a reference to Micorsoft Activex Object 2.8".

And can you show us the code that gives the error?
0
 
LVL 6

Expert Comment

by:BALMUKUND KESHAV
ID: 24311298
Mr.Gupta add the following references to your vb project :
Visual Basic for Applications
Microsoft Access 9.0 Object Library
Microsoft Activex Data Object 2.1 Library
OLE Automation

and then add the folloiwng to your vb project module
Sub connect1()
 dim conn as conneciton
  path = "F:\ajay\"
  Set conn = CreateObject("ADODB.Connection")
  conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                   "Data Source=" & path & ";" & _
                   "Extended Properties=""ACCESS 9.0;"";"
  Set OpenDBFConn = conn
End sub

bm keshav
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question