Link to home
Start Free TrialLog in
Avatar of CyberUnDead
CyberUnDead

asked on

Database Factory Parameters to Access

I want to date range my query by passing a begin date and end date.  My database is a Microsoft Access MDB.  I am guessing my code below is failing due to the way Access handles dates (with the # separator).

I am receiving data mismatch type error when I attempt to fill my dataadapter with my dataset result.

i.e. da.Fill(ds)

What is the proper way to pass dates to Access using DBFactory parameters?
Dim Parameter1 As DbParameter = factory.CreateParameter()
            Parameter1.ParameterName = "@BEGIN"
            Parameter1.DbType = DbType.DateTime
            Parameter1.Size = 10
            Parameter1.Direction = ParameterDirection.Input
            Parameter1.Value = BeginDate
            cmd.Parameters.Add(Parameter1)
 
            Dim Parameter2 As DbParameter = factory.CreateParameter()
            Parameter2.ParameterName = "@END"
            Parameter2.DbType = DbType.DateTime
            Parameter2.Size = 10
            Parameter2.Direction = ParameterDirection.Input
            Parameter2.Value = EndDate
            cmd.Parameters.Add(Parameter2)

Open in new window

Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Are BeginDate and EndDate declared as Date type variables?

AW
Avatar of CyberUnDead
CyberUnDead

ASKER

Arthur_Wood:

I have changed the input parameters of my subroutine from String to DateTime but still same data mismatch error.
Public Shared Sub Report(ByVal ID As String, ByVal BeginDate As DateTime, ByVal EndDate As DateTime)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CyberUnDead
CyberUnDead

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial