 zzzzzabc
		
			zzzzzabc
		
		
		
		
		
		
		
		
	
			06-15-2012 04:11 AM
Hi all,
I am making an application which contains Access database.
Database contains "User_Info" named table which has 4 columns (ID,Name, Designation,Scale) and "ID" is AutoNumber .
Now I am getting a problem at inserting Data to User_Info table.I am passing 3 arguments (Name,Designation,Scale) ,
I am not passing the ID bcoz it is AutoNumber.
How to insert this Data to table??
Please help
Tnx
Solved! Go to Solution.
 Yamaeda
		
			Yamaeda
		
		
		
		
		
		
		
		
	
			06-15-2012 08:08 AM
insert into user_info (D,Name, Designation,Scale) values (x, y, z, v);
/Y
 jcarmody
		
			jcarmody
		
		
		
		
		
		
		
		
	
			06-15-2012 08:19 AM
 nyc_(is_out_of_
		
			nyc_(is_out_of_06-15-2012 08:30 AM
His first problem was that he wasn't passing 4 parameters as required.
His second problem is that NAME is a reserved word in Access 2002 and later. http://support.microsoft.com/kb/286335
 jcarmody
		
			jcarmody
		
		
		
		
		
		
		
		
	
			06-15-2012 08:37 AM
@nyc_(is_out_of_here) wrote:
His first problem was that he wasn't passing 4 parameters as required.
I only passed three parameters.
 nyc_(is_out_of_
		
			nyc_(is_out_of_06-15-2012 08:56 AM - edited 06-15-2012 08:57 AM
I am not sure what you are saying.
His table has four columns/fields, so he needs to pass 4 parameters. That is his first problem, and that is what he posted about.
Once he fixes that, he will run into the second problem which is what you are displaying.
 PhillipBrooks
		
			PhillipBrooks
		
		
		
		
		
		
		
		
	
			06-15-2012 09:35 AM
The OP was correct in his statement that he did not include the value for the ID field because it has a value of AutoNumber. If you do not explicitly provide a value for a field in an INSERT statement, the default value defined when the table was created is used; in this case autonumber.
As Jim indicated, changing the field name is the only change required. I don't know who Bob is though 
 nyc_(is_out_of_
		
			nyc_(is_out_of_06-15-2012 10:04 AM - edited 06-15-2012 10:05 AM
I understand the concept of autonumber.
I always explicity include a NULL for the field that has the autonumber, e.g. INSERT INTO employee (id, firstname, lastname, address) VALUES (NULL, 'John', 'Doe', '123 Main Street'). Just what I am used to doing.
It wasn't clear to me what the OP had wired into the inputs of the DB Tools Insert Data.vi
I mistakenly believed the he had wired { ID,Name, Designation,Scale } for the columns input and was passing in only 3 elements in the data input. In which case, that wouldn't work.
 jcarmody
		
			jcarmody
		
		
		
		
		
		
		
		
	
			06-15-2012 10:07 AM
@nyc_(is_out_of_here) wrote:
I am not sure what you are saying.
His table has four columns/fields, so he needs to pass 4 parameters.
I'm saying that my code snippet only passes three parameters into a table that has four columns.
@PhillipBrooks wrote:
[...] I don't know who Bob is though
[...]
 nyc_(is_out_of_
		
			nyc_(is_out_of_06-15-2012 10:15 AM
@jcarmody wrote:
@nyc_(is_out_of_here) wrote:
I am not sure what you are saying.
His table has four columns/fields, so he needs to pass 4 parameters.
I'm saying that my code snippet only passes three parameters into a table that has four columns.
Yes, as I wrote above I mistakenly believed that the OP was passing 3 parameters but specifying 4 columns names which wouldn't work. With no VI, you interpreted his statements one way, and Yamaeda and I interpreted another way.