473,472 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cannot send ADO Date/Time parameter to a parameterized query

I have a table with 3 fields: UnitTime, Unit, and UnitCount
in an MDB database.

I have a query, qryWriteUnitOccupancy, that appends a record
to that table using 2 parameters: TimePoint, and PointUnit

I am using the following code to write a record:
For dUnitHour = FromDate To ToDate Step 1 / 24
With cmdUnit
.ActiveConnection = cnnUnit
.CommandType = adCmdText
.CommandText = "execute qryWriteUnitOccupancy"
Set prmUnit = .CreateParameter("TimePoint",
adDBTimeStamp, adParamInput, , Format(dUnitHour, "mm/dd/yyyy
hh:nn"))
.Parameters.Append prmUnit
Set prmUnit = .CreateParameter("PointUnit", adChar,
adParamInput, 5, sUnit)
.Parameters.Append prmUnit
.Execute
End With
Next dUnitHour

I run this, and no matter what the time is in dUnitHour, it
gets written to the table as a truncated date (no time). I
have stepped through this and watched the value of dUnitHour
step through hours, and I have run the query directly,
passing date/time and unit, and it writes just fine.

Any ideas?

Thanks,

Kevin Nechodom
University of Utah

Nov 13 '05 #1
2 4382
Try adDate, rather than adDBTimeStamp. They're not the same thing, and
AFAIK, Access doesn't support adDBTimeStamp.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Kevin Nechodom" <Ke************@nospamhsc.utah.edu> wrote in message
news:d4**********@vegh.ks.cc.utah.edu...
I have a table with 3 fields: UnitTime, Unit, and UnitCount
in an MDB database.

I have a query, qryWriteUnitOccupancy, that appends a record
to that table using 2 parameters: TimePoint, and PointUnit

I am using the following code to write a record:
For dUnitHour = FromDate To ToDate Step 1 / 24
With cmdUnit
.ActiveConnection = cnnUnit
.CommandType = adCmdText
.CommandText = "execute qryWriteUnitOccupancy"
Set prmUnit = .CreateParameter("TimePoint",
adDBTimeStamp, adParamInput, , Format(dUnitHour, "mm/dd/yyyy
hh:nn"))
.Parameters.Append prmUnit
Set prmUnit = .CreateParameter("PointUnit", adChar,
adParamInput, 5, sUnit)
.Parameters.Append prmUnit
.Execute
End With
Next dUnitHour

I run this, and no matter what the time is in dUnitHour, it
gets written to the table as a truncated date (no time). I
have stepped through this and watched the value of dUnitHour
step through hours, and I have run the query directly,
passing date/time and unit, and it writes just fine.

Any ideas?

Thanks,

Kevin Nechodom
University of Utah

Nov 13 '05 #2
I wasn't aware of the limitations of adDBTimeStamp usage on
Access queries. Learn something new! Anyway, the problem
was the fact that I was trying to reuse an ADODB.Command
object in a loop, and it just spit out the same thing every
time!

Thanks!

Kevin
Douglas J. Steele<NOSPAM_djsteele@NOSPAM_canada.com>
4/25/2005 6:53:25 PM >>>Try adDate, rather than adDBTimeStamp. They're not the samething, and
AFAIK, Access doesn't support adDBTimeStamp.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Kevin Nechodom" <Ke************@nospamhsc.utah.edu> wrote
in message
news:d4**********@vegh.ks.cc.utah.edu...
I have a table with 3 fields: UnitTime, Unit, andUnitCount
in an MDB database.

I have a query, qryWriteUnitOccupancy, that appends a

record
to that table using 2 parameters: TimePoint, and

PointUnit

I am using the following code to write a record:
For dUnitHour = FromDate To ToDate Step 1 / 24
With cmdUnit
.ActiveConnection = cnnUnit
.CommandType = adCmdText
.CommandText = "execute qryWriteUnitOccupancy"
Set prmUnit = .CreateParameter("TimePoint",
adDBTimeStamp, adParamInput, , Format(dUnitHour,

"mm/dd/yyyy
hh:nn"))
.Parameters.Append prmUnit
Set prmUnit = .CreateParameter("PointUnit",

adChar,
adParamInput, 5, sUnit)
.Parameters.Append prmUnit
.Execute
End With
Next dUnitHour

I run this, and no matter what the time is in dUnitHour,

it
gets written to the table as a truncated date (no time).

I
have stepped through this and watched the value of

dUnitHour
step through hours, and I have run the query directly,
passing date/time and unit, and it writes just fine.

Any ideas?

Thanks,

Kevin Nechodom
University of Utah

Nov 13 '05 #3

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

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Kenneth | last post by:
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in this Query I only want the salesdata for...
4
by: Tony | last post by:
Hey guys, I use Google Groups quite a bit as it is an enormous wealth of information, and now I need some help. I have created a query using parameters to capture a range of date, the date is...
2
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result....
1
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control...
4
by: bbdobuddy | last post by:
Hi, I have an ASP.net application with a connection to a sql database. I am writing a SQL statement to update some fields in a table but it won't run because it gives me an error that says ...
5
by: jeff | last post by:
i have written a program with date format as m/d/yyyy when i deploy it to client's machine, due to the client use d/m/yyyy format the Select SQL statement return some record wrongly. how can i...
14
by: eric.goforth | last post by:
Hello, I'm trying to convert a string to a date time in a C# web service. I'm passing in a string parameter and I have a localization setting in my Web.config file: My app is blowing up on...
0
by: MaartenVR | last post by:
sub: MS SQL server and (missing) ANSI DATE-datatype I’m working at a company who has developed a large client/server application in Delphi 6, with Interbase as the DB-server (both Borland...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.