Solved

ADO component

Posted on 2000-04-05
3
300 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
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

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now