Hi all,
I am attempting to use Access97 as the database to hold the results of a
python script. I seem to be able to make simple SELECT clauses work (like
SELECT * FROM TableName), but have not been able to figure out how to add a
WHERE clause to that (e.g., SELECT * FROM TableName WHERE myFieldName = 34)
This fails complaining that the wrong number of parameters are present.
I haved tried DAO36 and I have tried the ADO version with the same results.
Therefore I have to conclude it is my screwup!
Help in the forum or via email would sure be appreciated! (v.******@cox.net)
Here is the skeleton code:
import win32com.client
daoEngine = win32com.client.Dispatch('DAO.DBEngine.35')
sDBname = 'vpyAnalyzeDirectorySize.mdb'
sDB = 'c:\\documents and settings\\vic\\my
documents\\tools\\python25\\_myscripts\\'+sDBname
daoDB = daoEngine.OpenDatabase(sDB)
sSQL1 = 'SELECT * FROM T_Index2DirName'
daoRS = daoDB.OpenRecordset(sSQL1) # this works FINE and I can play
with the record set
#<snip>
hsDB = hash(sDB)
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB' # names are
all correct in mdb file
daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though the
record is there
daoRS.Close()
Traceback (most recent call last):
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\_MyScripts\TestForPosting 01.py", line 14, in
<module>
daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though
record is there
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\lib\site-packages\win32com\gen_py\00025E01-0000-0000-C000-000000000046x0x5x0.py",
line 523, in OpenRecordset
, Type, Options, LockEdit)
com_error: (-2147352567, 'Exception occurred.', (0, 'DAO.Database', 'Too few
parameters. Expected 1.', 'jeterr35.hlp', 5003061, -2146825227), None) 3 2163
On Jun 9, 10:17 am, "v.davis2" <v.dav...@cox.netwrote:
Hi all,
I am attempting to use Access97 as the database to hold the results of a
python script. I seem to be able to make simple SELECT clauses work (like
SELECT * FROM TableName), but have not been able to figure out how to add a
WHERE clause to that (e.g., SELECT * FROM TableName WHERE myFieldName = 34)
This fails complaining that the wrong number of parameters are present.
I haved tried DAO36 and I have tried the ADO version with the same results.
Therefore I have to conclude it is my screwup!
Help in the forum or via email would sure be appreciated! (v.dav...@cox.net)
Here is the skeleton code:
import win32com.client
daoEngine = win32com.client.Dispatch('DAO.DBEngine.35')
sDBname = 'vpyAnalyzeDirectorySize.mdb'
sDB = 'c:\\documents and settings\\vic\\my
documents\\tools\\python25\\_myscripts\\'+sDBname
daoDB = daoEngine.OpenDatabase(sDB)
sSQL1 = 'SELECT * FROM T_Index2DirName'
daoRS = daoDB.OpenRecordset(sSQL1) # this works FINE and I can play
with the record set
#<snip>
hsDB = hash(sDB)
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB' # names are
all correct in mdb file
Disclaimer: I've never used DAO.
That SQL statement appears to be incorrect/meaningless.
Don't you need something like
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = %d' % hsDB
?
You may need to read this (changing Office10 to whatever you have):
C:\Program Files\Common Files\Microsoft Shared
\Office10\1033\DAO360.CHM
Hello all.
Thanks for the help! John pointed out to me the flaw in my code:
Change:
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB'
to:
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = %ld' % hsDB
That did the trick. I had looked at the statement so often that it was
*obviously* correct.
John also pointed me to the DAO help file that I had not been able to find.
Dennis also pointed out the correction, but went on to educate me much more
on what I was trying to do.
BTW, I had searched extensivly on line for the answer before posting, but
was missing the obvious, stupid coding error.
Thanks to all for getting me back on track!
--Vic
"v.davis2" <v.******@cox.netwrote in message
news:Ok*********************@newsfe14.phx...
Hi all,
I am attempting to use Access97 as the database to hold the results of a
python script. I seem to be able to make simple SELECT clauses work (like
SELECT * FROM TableName), but have not been able to figure out how to add
a WHERE clause to that (e.g., SELECT * FROM TableName WHERE myFieldName =
34) This fails complaining that the wrong number of parameters are
present.
I haved tried DAO36 and I have tried the ADO version with the same
results. Therefore I have to conclude it is my screwup!
Help in the forum or via email would sure be appreciated!
(v.******@cox.net)
Here is the skeleton code:
import win32com.client
daoEngine = win32com.client.Dispatch('DAO.DBEngine.35')
sDBname = 'vpyAnalyzeDirectorySize.mdb'
sDB = 'c:\\documents and settings\\vic\\my
documents\\tools\\python25\\_myscripts\\'+sDBname
daoDB = daoEngine.OpenDatabase(sDB)
sSQL1 = 'SELECT * FROM T_Index2DirName'
daoRS = daoDB.OpenRecordset(sSQL1) # this works FINE and I can
play with the record set
#<snip>
hsDB = hash(sDB)
sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB' # names are
all correct in mdb file
daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though the
record is there
daoRS.Close()
Traceback (most recent call last):
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\_MyScripts\TestForPosting 01.py", line 14, in
<module>
daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though
record is there
File "C:\Documents and Settings\Vic\My
Documents\Tools\python25\lib\site-packages\win32com\gen_py\00025E01-0000-0000-C000-000000000046x0x5x0.py",
line 523, in OpenRecordset
, Type, Options, LockEdit)
com_error: (-2147352567, 'Exception occurred.', (0, 'DAO.Database', 'Too
few parameters. Expected 1.', 'jeterr35.hlp', 5003061, -2146825227), None)
I should point out that I don't do DAO (or ADO) -- and if I had to
code Python to access JET, I'd probably hijack a copy of mxODBC in order
to get a "sane" SQL interface.
I have successfully used the dejavu object-relational mapper (http://
projects.amor.org/docs/dejavu/1.5.0RC1/) to access MS ACCESS databases
recently.
Bestregards,
Stefaan. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Dugan |
last post by:
Hi,
has anybody come across a solution to running an Access97 database on
Windows XP. The situation I have is an Access 97 database that runs
perfectly from Win95/98 clients running Access97, the...
|
by: Mario Crevits |
last post by:
My name is Mario Crevits, I'm from Belgium (Roeselare) and I'm working with
Access97 for several years now. We are in an Access97-2000 migration
project. I'm writing a wizard for the end-users to...
|
by: Tony Ciconte |
last post by:
We are evaluating the prospect of integrating and/or using Crystal
Reports with some of our current products. Some of these are still in
Access 97 and are running well. Since we cannot include the...
|
by: lesperancer |
last post by:
I've got a sql server view that returns data, as a linked table to
access97 (qryPlannedPurPT)
this link table is used in an access query (qryPlannedPUR) that uses
all of the linked table fields...
|
by: IamKJVonly |
last post by:
I have office 97 which includes access97 and have built many access97 databases and use VB4 as the front end. I have just gotten a new computer which has 1 gig of memory on it and when I try to...
|
by: JJM0926 |
last post by:
I need some help with sorting some part numbers that are
alphanumeric. I have a table with a part number field which are in
the following format--sw1000, sw1200, sw2000, sw2600, sw3000, sw21000,...
|
by: Roger |
last post by:
I've got two tables in sql2005 which have an 'ntext' field
when I linked the first table in access97 last week using an odbc data
source the access-field type was 'memo'
when I link the 2nd...
|
by: Roger |
last post by:
can anyone explain this ?
originally using access97 with a linked table to an mdb backend, to
create a worksheet using
SELECT * FROM qryIPS WHERE location = 999
and it works fine with either...
|
by: Ramchandar |
last post by:
Hi,
I am creating reports using VBA code.
I have the same query in a querydef residing both in Access97 and Access2003. The result of this querydef is then moved to a table in Access97 and...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |