Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

.net + access: select.. where date>? + oledbparameter = datatype mi

Featured Replies

hi all,

i'm using an access db from .net. i have the following sql:

SELECT tblReservation.ReservationID 
FROM tblReservation INNER JOIN tblRoomReservation
ON tblReservation.ReservationID = tblRoomReservation.ReservationID
WHERE tblRoomReservation.RoomID=? AND
((tblReservation.CheckIn>=? AND tblReservation.CheckOut>=?) OR
(tblReservation.CheckIn<=? AND tblReservation.CheckOut<=?) OR
(tblReservation.CheckIn>=? AND tblReservation.CheckOut<=?) OR
(tblReservation.CheckIn<=? AND tblReservation.CheckOut>=?))

The question marks get filled in with OleDbParameters. The CheckIn and CheckOut colums are of type date/time, so the value for the field of the parameter also gets a value of type System.Date.

oSql.AddParameter("tblRoomReservation.RoomID", oRoom.Id)
oSql.AddParameter("tblReservation.CheckIn", dtCheckIn)
oSql.AddParameter("tblReservation.CheckOut", dtCheckOut)
...etc

This has worked this way for other queries, in fact the data gets into that same column via the same method without a problem. The query works fine in access (when i change the ?'s of course), but when i run it from .net, i get a "Datatype mismatch in criteria expression" error.

In a desperate attempt to fix all this, I even tried to change all ? into #?# and add the parameters a Strings, i.e. dtCheckIn.ToLongDateString, etc.. This gives me a "Syntax error in date in query expression"

Anyway, I'm getting a feeling this is because i try to compare the dates with > and < instead of plain =, but that's not what I need so.... As I said, it works in Access, so it must be possible. If someone could help me out here, that'd be really nice..


Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.