NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Update a field in an access database via TestStand

I want to read a value from a numeric field in an MS Access database, increment that value by one, and then update the database record that I got the value from with the new value. I am able to execute an Open Database step, execute a Open SQL Statement step with a SELECT query, execute a "Get" operation in a Data Operation step to get the value into a TestStand variable, and increment the value, but I'm at a loss for how to update the databse record with the incremented value.

I tried to execute another Open SQL Statement step with an UPDATE statement, but I get a "Specified value does not have the expected type." error. The TestStand variable type is a number, and the Data Type of the database field is Number. I've tried using long integer, double, and decimal as field sizes, but they all give me the same error.

I also tried to execute a "Set" operation with another Data Operation step against the original Statement Handle. When I do this, the Data Operation runs without error, but when I run a Close SQL Statement step against the statement handle I get an "ADODB.Recordset: Operation is not allowed in this context." error.

Any help would be appreciated.
0 Kudos
Message 1 of 3
(3,090 Views)
Scripter -
When you try to do a Set and Put, it is always good to explicitly set the statement's cursor type to something other than forward only, like keyset, and the lock type to something other than read-only. See if that helps...
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 3
(3,084 Views)
Scott,

Thanks for your reply. It lead me to the solution. The problem I was having is that I was doing a "Set" when I should have been doing a "Set and Put". Your suggestions on the cursor type and lock type didn't seem to have any effect, but I'll leave those changes in anyway. Thanks for your help.
0 Kudos
Message 3 of 3
(3,076 Views)