Solved

ADODB.Connection in vb 6.0

Posted on 2009-05-05
3
2,804 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
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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
A short article about problems I had with the new location API and permissions in Marshmallow
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now