Solved

ADO component

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

685 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