Posted on 2000-04-29
Last Modified: 2010-05-02
I have been reading that ADO better than DAO, till now i did not get the hang of it, this prog displays contents of different tables but it is very slow .

The form has a ado data control and a datagrid. i access connection not by code but by typing this in the connection propert<<<Data Link File = \\Server02\general\LeadDb.dsn>>>
and the record source is <<<select * from tblcustomers order by companyname>>>>
then I have option buttons to switch between different tables.

Now I know that the first connection may take long, but why when i click different option it takes the same. Is it my code or what is the best practice to follow.

Private Sub optTableChoice_Click(Index As Integer)

Me.Adodc1.Caption = "Please wait "
Select Case Index
Case 0
Me.Adodc1.RecordSource = "Select * From tblcustomers order by companyname"
Me.frameQuoteType.Visible = False
Case 1
Me.Adodc1.RecordSource = "Select * From tblContacts order by lastname"
Me.frameQuoteType.Visible = False
Case 2
Me.Adodc1.RecordSource = "Select * From tblenquiries order by enqdate desc"
Me.frameQuoteType.Visible = False
Case 3
Me.Adodc1.RecordSource = "Select * From tblquotes order by quotedate desc"
Me.frameQuoteType.Visible = True

End Select

Me.Adodc1.Caption = "Number Of Records is " & Me.Adodc1.Recordset.RecordCount
End Sub

connection in  control use Data Link File = \\Server02\general\LeadDb.dsn
record source in form select * from tblcustomers order by companyname
Question by:abidsml
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
  • 7
  • 4

Expert Comment

ID: 2762053
I never tried using Data Link maybe it is slower but have you tried using Connction String instead though ODBC or OLEDB ? Try it it might prove to be faster.

Author Comment

ID: 2762090
please start me up! how

Expert Comment

ID: 2762112
ok if you are using ADODC you choose its property pages by right clicking on the control then you chose properties. From there you will see a diolog box. You are going to be on the General Tab. There are 3 options one of them is DATA LINK the other 2 are ODBC and CONNECTION STRING. If you click on the connection string and click on the button build it will go the the next tab and there you will have to choose a provider. In your case you will have to choose the database that you are using. If you are using SQL SERVER choose SQL PROVIDER FOR SQL SERVER if you are using Access choose the one that says Microsoft JET.4.0 for OLEDB. Then click NEXT and you will have to select the database. After that you can press the TEST CONNECTION BUTTON TO SEE if your connection is success full. This what i just wrote is for connection string. If you want you can try to do it though ODBC by creating system dsn. If you havent done that you can do that from the property pages as well. After selecting the option ODBC You then click the new button to create a new system DSN or FILE DSN. File DSN is independant. You then again chose Provider for you database and then choose the database. You are then set.
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Author Comment

ID: 2762362

I did this but how can i make the path global, so when i install that on a user machine it will pick up the app.path.

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\APPLICATIONS\Progs\apr29\Clnt.mdb;Persist Security Info=False


Expert Comment

ID: 2762396
This is how i have it .

sCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db2.mdb;Persist Security Info=False"
cnAcct.Open sCon

if you put your database into your application folder this will know where to find it.

Expert Comment

ID: 2763092
has this helped to solve your problem ?

Author Comment

ID: 2763771
Marine, thank you for you feed back

well, this will work if i use it in code, but will not if i put it in the data control connection string property. I think the whole thing is confusing. but i am getting there, i am working more with data control by making early binding. if I can compare between these two things I think i will be ok.

What i am doing is:
1.add adodc1 to a form
2. make connection string in the property box <<< Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\APPLICATIONS\Progs\apr29\Clnt.mdb;Persist Security Info=False >>>>
3. my recordsource property box contains this<<< select * from tblContacts>>>
4. add a datalist1 to the form, make the datasource and rowsource boxes to the adodc1
5. choose the listfields, and boundcoloun
it works perfect, i am working more with it.
now I f i want to put this form in another machine, it will not find the .mdb file. so what is the equivelent to all that using code only and connections.

I can raise points if that is resolved
many thanks

Expert Comment

ID: 2763873
OK here is what i got now. I got this working.
I placed this into FOrmLoad event You can place it anywhere you like.

strPath = App.Path & "\db2.MDB"
With Adodc1
      .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db2.mdb;Persist Security Info=False"
      .CursorLocation = adUseClient
      .CursorType = adOpenStatic
      .CommandType = adCmdText
      .RecordSource = "SELECT * FROM tblBooks"
   End With
   With List1
      .DataField = "ISBN"
      Set .DataSource = Adodc1
   End With
   Do While Not Adodc1.Recordset.EOF
      List1.AddItem Adodc1.Recordset(0)

Accepted Solution

Marine earned 50 total points
ID: 2763874
ok sorry i didn't explain . see where it says .datafield you should place your own fieldname in there which you want to be displayed in ListBox.

Author Comment

ID: 2764165
thanks for your patience, I can see the simmilarty here.

Expert Comment

ID: 2764187
Great. Thanks for points. Happy programming :-)

Featured Post

Independent Software Vendors: 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

728 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