insert error

  • Thread starter Thread starter nate heaton
  • Start date Start date
N

nate heaton

I'm getting the following error attempting an insert:
Number of query values and destination fields are not the
same.

INSERT INTO table VALUES
('test','test','test','test','test','test')

I am trying to enter 6 values into a row with 7 fields.
However, 1 of those fields is a primary key autoNumber
data type. Therefore, I did not provide a value for it in
my insert statement.

When I remove the primary key field from my database I no
longer get the error. Can someone suggest what I am doing
wrong?
 
I'd suggest providing a list of fields you want filled:
INSERT INTO table (Field2,Field3,Field4,Field5,Field6,Field7) VALUES
('test','test','test','test','test','test')

HTH
- Turtle
 
I tried this method originally and received the same error.
-----Original Message-----
I'd suggest providing a list of fields you want filled:
INSERT INTO table
(Field2,Field3,Field4,Field5,Field6,Field7) VALUES
 
I was wrong when I said that I recieved the same error I
recieved a knew one:

Syntax error in INSERT INTO statement.

here is my insert:
INSERT INTO portfolio
(title,date,dimensions,medium,type,file) VALUES
('test','test','test','test','test','test')

here are my db fields

title
date
dimensions
medium
type
file

I have removed the primary key and still get an error.
The db seems to have the locked icon next to it even when
all programs using the db are closed. If I open access and
close it the locked icon goes away as it should. But when
I try my asp page again and then shut down the browser all
together and come back to the db it has a new locked icon.
I don't know if this has anything to do with my error
because I am not getting an error that indicates it is but
rather an insert error. Is there something wrong with the
way I am using the command object?

'Create the command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set objCmd.ActiveConnection = conn

objCmd.CommandText = "INSERT INTO portfolio
(title,date,dimensions,medium,type,file) VALUES
('test','test','test','test','test','test')"

objCmd.CommandType = adCmdText

'Execute the Command
objCmd.Execute
 
If Date is a date field, perhaps this will help:
INSERT INTO Portfolio ( Title, [Date], Dimensions, Medium,
File )
Roxie Aho
(e-mail address removed)
 
This would be true whether or not Date is a date field.
In addition, if the fields are not all text fields, this code will not
update them properly.

HTH
- Turtle

Roxie Aho said:
If Date is a date field, perhaps this will help:
INSERT INTO Portfolio ( Title, [Date], Dimensions, Medium,
File )
Roxie Aho
(e-mail address removed)
-----Original Message-----
I was wrong when I said that I recieved the same error I
recieved a knew one:

Syntax error in INSERT INTO statement.

here is my insert:
INSERT INTO portfolio
(title,date,dimensions,medium,type,file) VALUES
('test','test','test','test','test','test')

here are my db fields

title
date
dimensions
medium
type
file

I have removed the primary key and still get an error.
The db seems to have the locked icon next to it even when
all programs using the db are closed. If I open access and
close it the locked icon goes away as it should. But when
I try my asp page again and then shut down the browser all
together and come back to the db it has a new locked icon.
I don't know if this has anything to do with my error
because I am not getting an error that indicates it is but
rather an insert error. Is there something wrong with the
way I am using the command object?

'Create the command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set objCmd.ActiveConnection = conn

objCmd.CommandText = "INSERT INTO portfolio
(title,date,dimensions,medium,type,file) VALUES
('test','test','test','test','test','test')"

objCmd.CommandType = adCmdText

'Execute the Command
objCmd.Execute

.
 
Back
Top