bigboi214
bigboi214

Reputation: 21

querying a database using a date parameter

I am new to Visual Basic as well as Stackoverflow. I am querying certain fields from a database but receiving an error. here's my code:

Dim fifdate As Date = Now()
fifdate.AddDays(-15)

db.AddParam("collected", "N")
db.AddParam("printed", "Y")
db.AddParam("sent", "Y")
db.AddParam("date", fifdate)




Dim query As String = "Select * from badcheck where fldcollected = 
@collected And fldprinted = @printed And fldsentda = @sent "

'And fldsentdate > @date

db.ExcecuteQuery(query)

CheckedListBox1.DataSource = db.DBDT

if i add the commented out section into the query, i get the error "Data type mismatch in criteria expression", but the query works perfectly fine without it. I know for sure that fldsentdate is set as a date in the database. any suggestion on how the issue can be fixed?

Upvotes: 0

Views: 148

Answers (1)

bigboi214
bigboi214

Reputation: 21

i was able to fix the problem. I took the fifdate variable completely out and changed my parameter code to:

db.AddParam("date". date.today.AddDays(-15))

something was going wrong with fifdate, and I believe it may be due to Now(). i tried using fifdate directly with the query and was receiving the same error.

Upvotes: 2

Related Questions