UPDATE problem 
Author Message
 UPDATE problem

String.Format("UPDATE tblTasks SET Task = {0}, [Date] = {1}, [Time] =
{2}, Notes = {3} WHERE ID = {4}", txtTaskName.Text, " ", " ",
txtNotes.Text.ToString(), updateID)

Hi,
This statement doesn't work... do I have to use a SET for each value?
all the fields a text values so the type isn't the problem. The error
i get says i'm missing an operator near [Time] but i'm not sure. Any
ideas?

TIA, NF



Mon, 06 Dec 2004 21:37:08 GMT  
 UPDATE problem


Quote:
> String.Format("UPDATE tblTasks SET Task = {0}, [Date] = {1}, [Time] =
> {2}, Notes = {3} WHERE ID = {4}", txtTaskName.Text, " ", " ",
> txtNotes.Text.ToString(), updateID)

> Hi,
> This statement doesn't work... do I have to use a SET for each value?
> all the fields a text values so the type isn't the problem. The error
> i get says i'm missing an operator near [Time] but i'm not sure. Any
> ideas?

If you want to set an empty string or a null for something, you have
to either use the SQL keyword null or use single quotes ''.

So you should do String.Format("....", txtTaskName.Text, "''", "''",...

-c



Mon, 06 Dec 2004 22:00:24 GMT  
 UPDATE problem
hmmmmm i don't think that's the problem..... i have insert statements
that use string.format and i have put " " in there..... i'm almost
sure its a problem with how i wrote my update statement in general


Mon, 06 Dec 2004 22:29:54 GMT  
 UPDATE problem


Quote:
> hmmmmm i don't think that's the problem..... i have insert statements
> that use string.format and i have put " " in there..... i'm almost
> sure its a problem with how i wrote my update statement in general

Won't the statement end up like:

Update tblTasks SET [Name]= , [Description] = ,...

That's not valid SQL Syntax, last time I checked.

-c



Mon, 06 Dec 2004 22:33:19 GMT  
 UPDATE problem
On Thu, 20 Jun 2002 09:33:19 -0500, "Chad Myers"

well its not an empty string..... i AM supplying a space...........
"space" = " " and it works on my insert statements

Quote:



>> hmmmmm i don't think that's the problem..... i have insert statements
>> that use string.format and i have put " " in there..... i'm almost
>> sure its a problem with how i wrote my update statement in general

>Won't the statement end up like:

>Update tblTasks SET [Name]= , [Description] = ,...

>That's not valid SQL Syntax, last time I checked.

>-c



Tue, 07 Dec 2004 02:46:02 GMT  
 UPDATE problem
On Thu, 20 Jun 2002 09:33:19 -0500, "Chad Myers"

ok, you were right..... :) sorry, i'm a newbie at this, i added the
' ' things around the {#}s but now i get a different exception
message....
Data Type mismatch in criteria expression.
It might be cause ID is autoincrement but i checked the type in Access
and it said its a long integer. Any more ideas?
Thanks again

-NF

Quote:



>> hmmmmm i don't think that's the problem..... i have insert statements
>> that use string.format and i have put " " in there..... i'm almost
>> sure its a problem with how i wrote my update statement in general

>Won't the statement end up like:

>Update tblTasks SET [Name]= , [Description] = ,...

>That's not valid SQL Syntax, last time I checked.

>-c



Tue, 07 Dec 2004 02:56:29 GMT  
 UPDATE problem
If you're Updating, don't mess with the primary ID column
if it's autonumber. Just set all the rest of the fields and
leave the primary id alone.

Also, IIRC, one of your fields was a date. You can't set
'' to a date field. It's either a valid date or null if
you'd allowed nulls for that column

-c


Quote:
> On Thu, 20 Jun 2002 09:33:19 -0500, "Chad Myers"

> ok, you were right..... :) sorry, i'm a newbie at this, i added the
> ' ' things around the {#}s but now i get a different exception
> message....
> Data Type mismatch in criteria expression.
> It might be cause ID is autoincrement but i checked the type in Access
> and it said its a long integer. Any more ideas?
> Thanks again

> -NF



> >> hmmmmm i don't think that's the problem..... i have insert statements
> >> that use string.format and i have put " " in there..... i'm almost
> >> sure its a problem with how i wrote my update statement in general

> >Won't the statement end up like:

> >Update tblTasks SET [Name]= , [Description] = ,...

> >That's not valid SQL Syntax, last time I checked.

> >-c



Tue, 07 Dec 2004 03:17:42 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Pro*C Cursor-Update problem

2. MS ACCESS97 Multiple Table Join - Edit/Update Problems

3. CDaoRecordset::Update Problem

4. CDaoRecordset::Update Problems

5. ADO update problem

6. CRecordset::Update problem

7. Empty string Update problem!

8. 'Hard Question' Update Problem

9. Update problem!

10. OLE DB From VC++ 6.0 Delayed Update Problem on Insert

11. CRecordset Update Problem

12. Insert and update problem after changing db

 

 
Powered by phpBB® Forum Software