Solved

ADO component

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 51
TT Auto Dashboard 13 92
PHP preg_replace code convert to Delphi 14 55
VB6 - Scroll Mouse wheel on Picturebox 13 43
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

776 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