Solved

Conections

Posted on 2000-04-29
11
238 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
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.
0
 

Author Comment

by:abidsml
ID: 2762090
please start me up! how
0
 
LVL 6

Expert Comment

by:Marine
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.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:abidsml
ID: 2762362
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
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.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2763092
has this helped to solve your problem ?
0
 

Author Comment

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

Expert Comment

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

Author Comment

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

Expert Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updates not working for MS Windows 7 12 183
how to Classify of email (pdf attachments) 7 45
Problem to line 23 55
checkbox to hide entire section 10 43
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 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