wat is the problem here

cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <='" & Date.Today & "'", cn)

i want update the field status to "Available" when exp_date is less then todays date..
wat do i need to do.

What error do you get when executed.

"Data type mismatch in criteria expression."

If this is a date field, try # instead of '

cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <=#" & Date.Today & "#", cn)

i already fixed it, this all cause of the damn deference between VB.NET time format and SQL time thing, so i changed the whole thing to sql time, from all the queries from insert/Update too. so now no errors,

SQL thing is like this

cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <= now() ", cn)

Good to see you got it working Muhamin but be careful of subtle differences, especially between today's date and today's date and time:


the oledb SQL thing:
"Where exp_date <= Date()" - today's date
"Where exp_date <= now()" - today's date and time

The vb.net thing:

for today's date use:

cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <=#" & Date.Today & "#", cn)cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <=#" & Date.Today & "#", cn)

for today's date and time use:

cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <=#" & Date.Today & "#", cn)cmd1 = New OleDbCommand("Update tblParking SET status = 'Available' Where exp_date <=#" & Date.Now & "#", cn)

The reason your previous code didn't work was because you used ' instead of #

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.