Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADO component

Posted on 2000-04-05
3
Medium Priority
?
313 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 90 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses

618 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