Solved

Conections

Posted on 2000-04-29
11
234 Views
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 "
DoEvents
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.Refresh
Me.Adodc1.Refresh

Me.DataGrid1.Refresh
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
0
Comment
Question by:abidsml
  • 7
  • 4
11 Comments
 
LVL 6

Expert Comment

by:Marine
Comment Utility
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.
0
 

Author Comment

by:abidsml
Comment Utility
please start me up! how
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
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.
0
 

Author Comment

by:abidsml
Comment Utility
Thanks,

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



0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:Marine
Comment Utility
has this helped to solve your problem ?
0
 

Author Comment

by:abidsml
Comment Utility
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
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
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"
      .Refresh
   End With
   
   With List1
      .DataField = "ISBN"
      Set .DataSource = Adodc1
   End With
   Do While Not Adodc1.Recordset.EOF
      List1.AddItem Adodc1.Recordset(0)
      Adodc1.Recordset.MoveNext
   Loop
   
0
 
LVL 6

Accepted Solution

by:
Marine earned 50 total points
Comment Utility
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.
0
 

Author Comment

by:abidsml
Comment Utility
thanks for your patience, I can see the simmilarty here.
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
Great. Thanks for points. Happy programming :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 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

15 Experts available now in Live!

Get 1:1 Help Now