Solved

ADO component

Posted on 2000-04-05
3
306 Views
Last Modified: 2013-11-25
I wanna know how the normal connection is made by using that new ADO component.

I do this when I use that older DAO component:
MyData.DatabaseName = App.Path & "\database.mdb"
MyData.RecordSource = "SELECT * FROM Table"
MyData.Refresh

Could you give me an example.

Thanks in advance!
0
Comment
Question by:majala
[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 28

Expert Comment

by:AzraSound
ID: 2687700
after applying the control to your form, open its property window and click on custom, where it says "use a connection string" click the build command button and choose the database of your choice.  then click next.  you wll be provided with options you may or may not need. you will also be able to test your connection by pressing the test connection button.  then click ok and you will be brought back to the original dialog.  there is a recordsource tab there where you can specify your SQl statement. it should be ready to go.
0
 

Expert Comment

by:jdhananjay
ID: 2688593
Hi
Try this Out.
To use ADO you have to use ADO's Connection.receordset Property.
Try the Following code.
First u have to creat DSN using  ODBC32(from Control Pannel)

Dim con as new Adodb.Connection
dim rs as new Adodb.Recerdset

con.Mode = adModeReadWrite
con.ConnectionString = "Provider=MSDataShape.1;Persist Security Info=False;Data Source=TestDSN;Data Provider=MSDASQL"
con.open

rs.open "Select * from TABLE",con

Good Luck.If any problem mail me at hijai23@yahoo.com
Jay
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 30 total points
ID: 2688606
You can add an ADO Data Control component to the form (right mouse click on it after you have done so and selecte the ADODC Propertires) as suggested in the previous comment.. or.. Add a Data Environment (Vb Menu Projects).. or simply hardcode it.. <smile>.

----------------------------------
An example that opens a connection, opens a recordset, places three fields into three listboxes, and then closes the recordset and connection.

<----- Code Begin ----->

   Dim db As New ADODB.Connection
   Dim strConnect As String
   strConnect = "Provider=Microsoft.Jet.OLEDB.3.51;" _
      & "Data Source=c:\MyPath\MyFile.mdb"
   db.ConnectionString = strConnect
   db.Open
   
   Dim rs As New ADODB.Recordset
   rs.ActiveConnection = db.ConnectionString
   rs.CursorType = adOpenStatic
   rs.Source = "SELECT * FROM MyTable"
   rs.Open
   
   Do Until rs.EOF
      List1.AddItem rs!MyColumn1
      List2.AddItem rs!MyColumn2
      List3.AddItem rs!MyColumn3
      rs.MoveNext
   Loop
     
   rs.Close
   Set rs = Nothing
   Set db = Nothing

<----- Code End ----->
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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