LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access DB insert Problem

Solved!
Go to solution

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

0 Kudos
Message 1 of 12
(2,932 Views)

insert into user_info (D,Name, Designation,Scale) values (x, y, z, v);

 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 12
(2,911 Views)

undefined

 

That's probably your problem.  Rename that field and Bob will be your uncle.

 

undefined

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 12
(2,907 Views)

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

0 Kudos
Message 4 of 12
(2,905 Views)

@nyc_(is_out_of_here) wrote:

His first problem was that he wasn't passing 4 parameters as required.


I only passed three parameters.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 12
(2,903 Views)

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.

 

 

0 Kudos
Message 6 of 12
(2,899 Views)
Solution
Accepted by topic author zzzzzabc

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 Smiley Tongue

 

undefined


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 7 of 12
(2,888 Views)

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.

 

 

 

 

 

 

0 Kudos
Message 8 of 12
(2,880 Views)

@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 Smiley Tongue [...]

 


 Bob's your uncle!

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 9 of 12
(2,874 Views)

@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.

 

 

Message 10 of 12
(2,871 Views)