Access97, COM, and printing a date field - Problem.

rayleyva at my-deja.com rayleyva at my-deja.com
Tue May 9 14:02:28 EDT 2000


After much reading I've chosen to use the win32com access method to get
to my Access97 data.  It's working great except when I try to print out
a field that contains date information ... here's some code snippets.

import win32com.client

sql = """ ... Waaaay long .... """
engine = win32com.client.Dispatch("DAO.DBEngine.35")
db = engine.OpenDatabase(r"c:\winshare\vendors97.mdb")
rs = db.OpenRecordset(sql1)
rs.MoveFirst()

... misc html formatting stuff ...

#--- use to enumerate the field #, name, and value ---
#--- If there's a better way please let me know, thanks. ---

#x = 0
#while rs.Fields(x).Name > " ":
#    print "<TR><TH WIDTH=5% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-2> NAME
(",x,"): </FONT></TH>"
#    print "<TH WIDTH=10% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-
2>",rs.Fields(x).Name,"</FONT></TH>"
#    print "<TH WIDTH=65% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-
2>",rs.Fields(x).Value,"</FONT></TH>"
#    x = x + 1

#--- to print out the information formatted for my html tables. ---

while not rs.EOF:
    print "<TR><TH WIDTH=5% VALIGN=TOP><FONT SIZE=-2>",rs.Fields
("tblTasks.ID").Value,"</FONT></TH>"
    print "<TH WIDTH=10% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-2>",rs.Fields
("Customer").Value,"</FONT></TH>"
    print "<TH WIDTH=65% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-2>",rs.Fields
("Task").Value,"</FONT></TH>"

#--- Print out the dates ... here's the problem, it prints nothing.

    print "<TH WIDTH=10% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-2>",rs.Fields
("DateEnt").Value,"</FONT></TH>"
    print "<TH WIDTH=10% ALIGN=LEFT VALIGN=TOP><FONT SIZE=-2>",rs.Fields
("ScdDate").Name,"</FONT></TH></TR>"
    rs.MoveNext()

Any help at all would be greatly appreciated.

Thanks
Ray Leyva


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list