Tuesday, March 20, 2012

query error: invalid object name

I'm getting the following error when I try to add a new record to the db:
System.Data.SqlClient.SqlException: Invalid object name 'Pub_Points'.
My table is called Pub_Points. I've had an insert working before.
This is the SQL string that I'm trying to send:
INSERT INTO Pub_Points ('PPName','Encoder_URL','Connect_Type','Archive','Creation_Date') VALUES ('fu','barr','local ','19/26/2005 13:35:27')

Yet updating an existing record during the same run works fine:
UPDATE Pub_Points SET PPName='foo ', Encoder_URL='bar', Connect_Type='remote ', Archive='0' Where ID='114'
So it can't be a problem finding the table itself.
Only two things I can see that are different:
- the Insert procedure first creates and attaches the formatted date string (which you see already inserted in the Insert query)
- the database has an auto-generating key field 'ID' (which you see being referenced in the UPDATE query)
but I don't see how either of those things would give me this error.
Ideas?
Get rid of the quotes around your column names:
INSERT INTO Pub_Points (PPName,Encoder_URL,Connect_Type,Archive,Creation_Date) VALUES ('fu','barr','local ','19/26/2005 13:35:27')

Marcie

No comments:

Post a Comment