Pezzzz
Pezzzz

Reputation: 748

SQL UPDATE syntax error

I am trying to update some data within a table in ms-access using vb.net. However I am getting an error when trying to run the code. My Query is:

Query = "UPDATE tabDatafiveMinutely SET PAR0050=308.3925 WHERE TimeValue = #16 May 2012 14:30:00#"

The error I get is:

No value given for one or more required parameters.

Does anyone have anyone have any ideas on how to solve this?

EDIT:

The Syntax is Correct I had a problem with the Database

Upvotes: 0

Views: 469

Answers (4)

Arvo
Arvo

Reputation: 10580

Promoted to answer as requested :)

This error means that some field names, specified in query, are not present in table (or are reserved words).

Upvotes: 2

Jack Gajanan
Jack Gajanan

Reputation: 1670

use this

Query = "UPDATE tabDatafiveMinutely SET PAR0050=308.3925 
         WHERE TimeValue = CONVERT(DATETIME, '2012-05-16', 102)

for other date format

Date -100- MMM DD YYYY' -- Feb 5 2010
Date -101- MM/DDYYYY'
Date -102- YYYY.MM.DD'
Date -103- DD/MM/YYYY'
Date -104- DD.MM.YYYY'
Date -105- DD-MM-YYYY'
Date -106- DD MMM YYYY' --ex: 03 Jan 2007
Date -107- MMM DD,YYYY' --ex: Jan 03, 2007
Date -108- MMM DD YYYY' -- Feb 5 2010
Date -110- MM-DD-YYYY' --02-05-2010
Date -111- YYYY/MM/DD'
Date -112- YYYYMMDD' -- 20100205
Date -113- DD MMM YYYY' -- 05 Feb 2010

to convert date to text use like this

CONVERT(VARCHAR(12),getdate(),113)

Upvotes: 1

Pranay Rana
Pranay Rana

Reputation: 176956

just dont make use of # instead of that us ' might resole your issue

UPDATE tabDatafiveMinutely SET PAR0050=308.3925 
  WHERE TimeValue = '16 May 2012 14:30:00'

Upvotes: 1

SysDragon
SysDragon

Reputation: 9888

The date must be between quotes, I think:

Query = "UPDATE tabDatafiveMinutely SET PAR0050=308.3925 WHERE TimeValue = '#16 May 2012 14:30:00#'"

Upvotes: 0

Related Questions