473,772 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with converting DAO to ADO

I'm looking at converting DAO to ADO in my app. All of my DAO connections
are of the following structure:

Dim wsName As DAO.Workspace
Dim dbName As DAO.Database
Dim rsName As DAO.Recordset

Set wsName = DBEngine.Worksp aces(0)
Set dbName = wsName.OpenData base(CurrentPro ject.FullName)
Set rsName = dbName.OpenReco rdset("SQL Statement")

I'm a real newbie with ADO and don't feel at all comfortable with it. Now to
convert to ADO, something like:

Dim cnnName As New ADODB.Connectio n
Dim rsName As New ADODB.Recordset

and here's where I start to get confused:

Set cnnName = Application.Cur rentProject.Con nection????
rsName.Open "SQL Statement" ????

Since I have several hundred of these DAO constructs, I'm trying to figure
out if there is a way I could write code to accomplish the conversion.

Thanks for any help.

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200602/1
Feb 17 '06
32 12517
"Kjell Harnesk" <no****@please. com> wrote in message
news:1w******** *************** *******@40tude. net...
On 16 Feb 2006 20:01:43 -0800, Lyle Fairfield wrote:

or marinated artichoke hearts


What is artichoke?

Like a potato without the flavor.

--
Darryl Kerkeslager
Feb 17 '06 #11

Larry Linson wrote:
"Lyle Fairfield" <ly***********@ aim.com> wrote

Do you think it serves any purpose to clutter the newsgroup with old quotes
that _appear to_ but, in fact, no longer _do_ contradict Allen Browne's
perfectly accurate comments about the "classic ADO" of which you are the
"world's greatest fan" versus ADO.NET and using DAO when the database engine
is Jet?
http://msdn.microsoft.com/data/mdac/...dacroadmap.asp
To be completely honest, Lyle, you should write "Microsoft said" (past
tense).
http://msdn.microsoft.com/data/mdac/...dacroadmap.asp
Larry Linson
Microsoft Access MVP


Feb 17 '06 #12
The first link to the msdn article (revised in September of 2005) states
under a heading entitled: Obsolete Data Access Technologies.

Obsolete technologies are technologies that have not been enhanced or updated
in several product releases and that will be excluded from future product
releases. Do not use these technologies when you write new applications. When
you modify existing applications that are written using these technologies,
consider migrating those applications to ADO.NET.

Data Access Objects (DAO): DAO provides access to JET (Access) databases.
This API can be used from Microsoft Visual Basic®, Microsoft Visual C++®, and
scripting languages. It was included with Microsoft Office 2000 and Office XP.
DAO 3.6 is the final version of this technology. It will not be available on
the 64-bit Windows operating system.
Can I migrate to ADO.NET even if my application remains a desktop application.
?

Lyle Fairfield wrote:
Do you think it serves any purpose to clutter the newsgroup with old quotes
that _appear to_ but, in fact, no longer _do_ contradict Allen Browne's
perfectly accurate comments about the "classic ADO" of which you are the
"world's greatest fan" versus ADO.NET and using DAO when the database engine
is Jet?


http://msdn.microsoft.com/data/mdac/...dacroadmap.asp
To be completely honest, Lyle, you should write "Microsoft said" (past
tense).


http://msdn.microsoft.com/data/mdac/...dacroadmap.asp
Larry Linson
Microsoft Access MVP


--
Message posted via http://www.accessmonster.com
Feb 17 '06 #13
Larry Linson wrote:
Perhaps they are also enhancing "classic ADO" for Office 2007. Can you
provide a reference to a statement that they are?


ADO is a technology independent of Access and Office. I don't
understand this question at all.
Will ADO die? If MS is willing to have millions of ADP, ASP, VB, HTA,
etc applications cease to function I suppose it could.
Will new versions of Office be able to use ADO? Well, if they can't
they won't be backwards compatible with ADPs and many thousands of
other applications. What are the chances of that?

Feb 17 '06 #14
Larry Linson wrote:
I had really thought you were "here to help," Lyle, but perhaps I was
mistaken.


UPDATE [SELECT s.*, ns.* FROM Suppliers AS s INNER JOIN
Northwind.Mdb.S uppliers AS ns ON s.SupplierID=ns .SupplierID]. AS
SubQuery SET s.CompanyName = ns.CompanyName;

The syntax here must be exact.

If you are using JET 4.0 then you are laughing because you can
substitute ( ) for [ ] for the subquery and omit the "." and alias as
in:
UPDATE (SELECT s.*, ns.* FROM Suppliers AS s INNER JOIN
Northwind.Mdb.S uppliers AS ns ON s.SupplierID=ns .SupplierID) SET
s.CompanyName=n s.CompanyName

This would mean that you can use [] to delimit your external db,
required if the path has spaces. [] are not nestable as delimiters

Application.Fol lowHyperlink "C:\Documen ts and Settings\Lyle
Fairfield\My Documents\Word\ Materialism.doc "

Split should be available in any version of Access >= 2000 (9).
If for some reason (I can't think of one) you need a UDF you could use
one of the many you could find with a Google search. Here's mine ...
not so extensively tested:

' change this if it does not meet your needs
Const SplitLimit As Long = 4096

Public Function SplitB(ByVal SplitString As String, _
Optional ByVal Delimiter As String = " ", _
Optional Element As Long) As Variant
Static aSplit() As Variant
Dim Position As Long
If Element = 0 Then ReDim aSplit(SplitLim it)
Position = InStr(SplitStri ng, Delimiter)
If Position = 0 Then
aSplit(Element) = SplitString
ReDim Preserve aSplit(Element)
SplitB = aSplit
Else
aSplit(Element) = _
Trim(Left(Split String, Position - 1))
SplitB = _
SplitB(Mid$(Spl itString, Position + 1), Delimiter, Element + 1)
End If
End Function

I suggest a two step approach, eg:
With DBEngine(0)(0)
.Execute "DELETE * FROM Suppliers WHERE SupplierID IN (SELECT
SupplierID FROM Northwind.mdb.S uppliers)"
.Execute "INSERT INTO Suppliers SELECT * FROM
Northwind.mdb.S uppliers"
End With

This may seem inefficient, but TTBOMK it's what databases do for an
update anyway (that is mark for deletion and append).

Public Function ShowTime( _
ByVal hours As Long, _
ByVal minutes As Long, _
ByVal AmorPm As Long) As String
Dim d As Date
d = TimeSerial(hour s + (AmorPm - 1) * 12, minutes, 0)
ShowTime = Format(d, "hhnn")
' or
' ShowTime = Format(d, "hh:nn ampm")
End Function

As a last resort I would use an independent connection eg
Dim c As ADODB.Connectio n
Set c = New ADODB.Connectio n
With c
..Open _
"PROVIDER=SQLOL EDB.1;" _
& "INTEGRATED SECURITY=SSPI;" _
& "INITIAL CATALOG=FFDBA_E SO_LOCAL;" _
& "DATA SOURCE=FFDBA\SQ LEXPRESS"
..Execute "spShrinkDataba se"
End With

Private Sub SomeWouldCallAH ack()
Dim z As Long
On Error Resume Next
With References
.AddFromFile "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\Acces s\ESO\EsoAdmin. adp"
.AddFromFile "C:\Program Files\Common Files\Microsoft
Shared\VBA\VBA6 \VBE6EXT.OLB"
With VBE.VBProjects( "EsoAdmin").VBC omponents
For z = 1 To .Count
Debug.Print .Item(z).Name
Next z
End With
.Remove References("VBI DE")
.Remove References("Eso Admin")
End With
On Error GoTo 0
End Sub

Could you be talked into

On Error Resume Next
Kill "C:\Documen ts and Settings\t83329 9\Desktop\Extra cts\*.*"
On Error Goto 0 'or somewher else

From: Peter Tyler - view profile
Date: Fri, Feb 10 2006 7:53 am
Email: "Peter Tyler" <PLTy...@gmail. com>
Groups: comp.databases. ms-access
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author

I am having a hard time trying to code around this. I have a checkbox
field in a MSAccess table called "100Fund" which is identical in
structure to other checkbox fields in the same table. I have a combo
box listing the various fields in the table for the user to select as a
table filter. If I use the following code in VB6 - where the user
selects the field "100Fund" - I get the above error:

Dim varchoice As String
varchoice = cmbFilter.Text
Adodc1.RecordSo urce = "select * from [A Table] where " & varchoice & "
= True order by LastName"
Adodc1.Refresh

All other checkbox fields work fine when selected. I appreciate that
it has to do with the field name starting with "100" but varchoice is
clearly a string variable. Using Cstr() doesn't help.

Any ideas? Thanks in advance!

Peter Tyler

Reply Rate this post: Text for clearing space

From: Lyle Fairfield - view profile
Date: Fri, Feb 10 2006 8:00 am
Email: "Lyle Fairfield" <lylefairfi...@ aim.com>
Groups: comp.databases. ms-access
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author

You might try:
where [" & varchoice & "]

Reply Rate this post: Text for clearing space

From: Peter Tyler - view profile
Date: Sat, Feb 11 2006 1:23 am
Email: "Peter Tyler" <PLTy...@gmail. com>
Groups: comp.databases. ms-access
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author

It works well. Thanks Lyle!

But why? I would normally only use square brackets where the field (or
table) name has a space.

Peter

Reply Rate this post: Text for clearing space

From: Lyle Fairfield - view profile
Date: Sat, Feb 11 2006 6:02 am
Email: "Lyle Fairfield" <lylefairfi...@ aim.com>
Groups: comp.databases. ms-access
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author

from help:

The setting or return value is a String that specifies a name. The name
must start with a letter. The maximum number of characters depends on
the type of object Name applies to, as shown in Remarks. It can include
numbers and underscore characters ( _ ) but can't include punctuation
or spaces.

Reply Rate this post: Text for clearing space

From: Peter Tyler - view profile
Date: Mon, Feb 13 2006 2:16 pm
Email: "Peter Tyler" <PLTy...@gmail. com>
Groups: comp.databases. ms-access
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author

OK thanks.

Peter

Feb 17 '06 #15
What Desktop Application? To learn more about what Access 12 will be
like one could read:
http://blogs.msdn.com/access/
VB6? My recollection is that installation of some .NET things
uninstalled it, but I might not be remembering correctly. (Some things
happen when you're 68; other things not enough).

How long will an Access or VB6 application using DAO or ADO run on the
Windows platform (as opposed to being able to be developed). Who knows?
If we were sticking with 32 bit then one could say ... ten years ...
twenty years. But we're going to 64 bit (I'm told). Will MS, for sure,
allow us to run DBase III apps from the 1980's in them ... as we can
now (haven't checked lately!)? History says, "Yes". But history could
be wrong.

Feb 17 '06 #16
"robert d via AccessMonster.c om" <u6836@uwe> wrote in
news:5c00192105 204@uwe:
This information along with my other posts will provide me with a
solid basis for strongly supporting Access as a development
environment for a front-end, which, oh by the way, has a native
database known as Jet, but which will not be used in this
implementation (SQL Server) so there are no concerns about
scalability, etc.


Well, you may not want to *tell* them, but Jet *will* be used if you
use ODBC, since Jet processes all ODBC data operations. This
occasionally causes performance problems, where Jet guesses wrong
about what the most efficient way to process the SQL is, but ADO
does the same thing and it guesses wrong, too (often in much worse
ways that are harder to work around).

That Jet is involved is not a bad thing.

The only thing that matters is that Jet is not your back end data
store.

And, BTW, Jet is involved in an MDB file no matter whether you use
DAO or ADO or ODBC or what, because the forms and reports and so
forth are stored in Jet data tables. The only way to avoid Jet
entirely is to use an ADP, and all of the vociferous defenders of
ADPs have now abandoned using them after encountering insurmountable
problems with them.

There was never any rational reason to want to avoid Jet in the
first place -- Microsoft created the ADP to address an irrational
fear of ignorant developers. Jet is a remarkable technology, both as
a data store and as a data access engine (it's Jet ISAMs that
provices Access with its ability to connect to myriad different
types of data). As a data store, it has its limitations and its very
often appropriate to upsize an app to a server back end in order to
support more users, in order to get five 9s of reliability, in order
to gain 24/7 up-time with hot backups, in order to improve
performance with applications that manipulate very large datasets,
or in order to handle extremely large datasets that are too large
for Jet's 2GB limitation.

But Jet is still very, very good.

Microsoft has bet on it big time by using it in all its copies of
Windows starting with Windows 2000 -- the data store for Active
Directory is Jet. So, Microsoft thinks Jet is a pretty good database
engine for certain kinds of applications.

Also, I think that Microsoft has an agenda that is is promoting to
try to move its customers to more expensive database projects. SQL
Server licenses are more expensive than Jet, which has no per user
licensing. Combine Access as front end with SQL Server as back end
(which is what most of the design engineering in Access 2000 was
aimed at) and Microsoft is getting revenue for the copy of Access
and for the user license for SQL Server. If that app uses Jet,
instead, Microsoft gets less revenue.

I think MS wishes Jet were not so good, to be honest, and that's
part of the reason they started deprecating it.

That campaign has worked prettye well, I guess, if your customers
have swallowed the anti-Jet Kool Aid. But the reputation of Jet is
entirely based on misinformation, ignorance and misuse of Jet by
people who never bothered to understand what it's limitations and
strengths actually were.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 17 '06 #17
"Larry Linson" <bo*****@localh ost.not> wrote in
news:UFcJf.7829 6$_D1.61030@trn ddc03:
Have not the "knowledgea ble 'Softie insiders" blogged that the
Access development team has taken over what used to be called Jet
and what used to be called DAO, for additional development in the
next version (apparently now officially named Office 2007)?


No. They've said that they are creating their own private
Access-specific version of Jet based on canonical Jet, which is
owned by the Jet team, a part of the Windows development
group.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 17 '06 #18
"Lyle Fairfield" <ly***********@ aim.com> wrote in
news:11******** **************@ z14g2000cwz.goo glegroups.com:
Microsoft says:
* ADO: ActiveX Data Objects (ADO) provides a high-level
programming
model that will continue to be enhanced. Although a little less
performant than coding to OLE DB or ODBC directly, ADO is
straightforward to learn and use, and can be used from script
languages such as Microsoft Visual Basic® Scripting Edition
(VBScript) or Microsoft JScript®.


This is a very odd quotation. Can you provide the URL for it?
Th reason I think it's very odd is that it restricts the use of ADO
to VBScript and JScript, which would, I think, actually support
Allen's point, that ADO is not all that appropriate for use in
Access. I note that plain VBA is not mentioned in the
quotation.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 17 '06 #19
"Larry Linson" <bo*****@localh ost.not> wrote in
news:UFcJf.7829 6$_D1.61030@trn ddc03:
Do you think it serves any purpose to clutter the newsgroup with
old quotes that _appear to_ but, in fact, no longer _do_
contradict Allen Browne's perfectly accurate comments about the
"classic ADO" of which you are the "world's greatest fan" versus
ADO.NET and using DAO when the database engine is Jet?


I don't think the quotation contradicts Allen at all -- it specifies
the use of ADO in VBScript and JScript, but not in any other
environment, such as VBA or VB. That would exclude Access, no?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 17 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4813
by: Rex_chaos | last post by:
Hi all, I have a question about datatype converting. Consider the following types std::complex<double> and struct MyComplex { double re, im; }
4
1767
by: jipster | last post by:
hi, i need help converting this java program to C++...are there any programs or nething that could be used to do this faster?? class hw2 { static public void main (String args) { hw2.test();} Board board = new Board(8); if ( board.fillInRemainingLevels() ) board.print(); else System.out.println("Couldn't find solution");
3
3363
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
3
1456
by: alyssa | last post by:
Hi guys, May i know how to declare a string of binary data and pass it to the method? For example, int a={10010001120420052314} is it correct? and if i have receive the binary data, may i know how to separate them and store each of them inside a variable such as int cust_id?is it possible? For example, the first four bits is the customer id, the second four bits is the call id and third 8 bits is the date and the remaining is the time.. ...
4
3097
by: Clark Stevens | last post by:
I have a program that I'm converting from VB6 to VB.NET. It reads in a text file containing barcode numbers and their corresponding descriptions. Then the user enters the barcode number and the program finds the matching barcode description. In VB6 I used an UDT to store the barcode number along with the description. Then I declared an array of the barcode UDT. I'm thinking of converting the UDT to a structure in VB.NET and doing...
13
3973
by: Paraic Gallagher | last post by:
Hi, This is my first post to the list, I hope somebody can help me with this problem. Apologies if it has been posted before but I have been internet searching to no avail. What I am trying to do is provide a simple method for a user to change a config file, for a test suite. The config file consists of a number of keys, eg. build number, target device, etc.
16
5448
by: manmit.walia | last post by:
Hello All, I have tried multiple online tools to convert an VB6 (bas) file to VB.NET file and no luck. I was hoping that someone could help me covert this. I am new to the .NET world and still learning all help would be greatly apperciated. Attribute VB_Name = "Module1" Option Explicit
2
1761
anukagni
by: anukagni | last post by:
Hi, iam having an database for that i have created an user manual includes help topics ..I prepared in the word format and i want to covert this to html help . Iam having Ms Html workshop but i found to hard to create any body sugess me to create an html help by converting the word matters too.... needed solution ... thanks in advance.. thanks, anukagni
10
5729
by: minterman | last post by:
1. the program needs to convert btu to jules 2. Convert calories to joules 3. Convert joules to joules 4 exit the program. if the user type anything other than 1-4 the program should print a error message. here is my code. import java.util.Scanner;
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.