Solved

ADODB.Connection in vb 6.0

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

19 Experts available now in Live!

Get 1:1 Help Now