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
Solved

ADODB.Connection in vb 6.0

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

860 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