Solved

ADODB.Connection in vb 6.0

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

738 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