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
Who is Participating?
MarineConnect With a Mentor Commented:
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.
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.
abidsmlAuthor Commented:
please start me up! how
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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.
abidsmlAuthor Commented:

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

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.
has this helped to solve your problem ?
abidsmlAuthor Commented:
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
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)
abidsmlAuthor Commented:
thanks for your patience, I can see the simmilarty here.
Great. Thanks for points. Happy programming :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.