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
  • 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.
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.


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

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 Compile Compatibility Issue 4 102
Looking for VB6 code to read SQL table export it to ascii 8 38
using web browser with BING 40 119
VB6 ListBox Question 4 42
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now