10-09-2012 06:50 AM
Hey guys,
I am looking to write data to a database after each test step. I want to send a boolean Pass/Fail and a string name of test. I can read data and use parameters for my test step but i am having difficulty sending results to a different DB. I have followed the tutorial from http://www.ni.com/pdf/manuals/371525a.pdf for writing data to database at at fig 5.2. I have no run test block in the vi below but i want to add a boolean and a string to the bundle by name but I get errors can anyne have a quick look and help me out. I want to test that my database reads string value and a boolean before i add my run test block.
Thanks.
Damien
Solved! Go to Solution.
10-09-2012 08:05 AM
Damien,
It's not clear how you're organizing your database table. Are you planning on having one row per test that contains results for all the test steps or a separate row for each test step that contains only the results for that step?
If you're planning on having one row per test with a column for each test step (as implied by the column names in your VI), then inserting data after each step is going to be more complex. You'll have to insert the row after the first step, then keep a reference to it and update it for the subsequent steps.
Inserting a new row for each step is easier when you're running the test, but it makes retrieving the results from the database more difficult.
Sorry if this is kind of vague, but if you can provide more details on your table layout I can get more specific.
10-09-2012 08:06 AM
You have several errors in the VI.
I attempted to fix this VI for you but I'm not sure I understand your requirements. The VI that I attached will write a string ("some string") to column Step1 and a boolean to column Step2 of table StepResults (whatever table name you put in the string control StepResults) and will do this the number of time specified by Numeric which is wired to the N terminal of the for loop. Note if N = 0 as it does by default in the code that you sent me, then nothing will be written to the data base.
All that said, your last sentence stated that you wished to read from the database. The attached VI is attempting to write to the database, not read from it. Please post back if you need help reading from the database.
10-09-2012 08:32 AM
Thanks for the reply guys, really appreciate it.
Sorry if i havent made my question clear. For instance I have 10 test steps after each test step i get a pass/fail. I would like to write back to the database after the 10 test steps saying PPPPPFFFFF in one row. Above each P or F will be the test step name for that colunm. It was suggested to me i might need a paste append function.
I have the read from database working fine and can extract the info i need no problem. My test block where i receive PPPPPFFFFF is a vision block i hevent completed just yet. Can ye give me suggestions or alter my code so i can achieve what i set out to do. Thanks so much.
Damien
10-09-2012 08:54 AM
I believe you want a database table that has 10 columns, named Step0 through Step9 (or whatever is appropriate). The data type for all columns is boolean. With these assumptions in mind you have two options:
If you need further help from here please let me know which route you wish to go and if possible please send me the table schema.
10-09-2012 09:09 AM
The first option is precisely what i require as my test steps should only last 30 seconds in total. A couple of questions regarding your suggestions my experience is rather limited so;
1. Each input into the bundle by name function is from each test step?
2. To buffer the results just pass them straight through each state or how would i achieve this?
I have attached the vi perhaps slight alterations would point me in the right direction.
Thanks very much very helpful.
damien
10-09-2012 10:37 AM
Check out this modification of your VI and let me know if you have questions. One non-obvious thing to point out, I am using the function "Array to Cluster", to make this work for your application, you MUST right click on that function and select "Cluster Size". I have already set this to 10 but if that number changes then let me know.
10-10-2012 02:35 AM
Hi Charles,
Thats great Charles thank you very much for your assistance, just a couple of questions then on this vi? Apologies if i am going off point here now but i am still learning labview.
My test block is in a state machine structure so after the 10 test steps my next state will be this writing to database.vi. Where in this vi do my results from the previous test steps link in. Is it the array to cluster and leave out the for loop. Or how would i get the results from the previous states into this vi? I can attach my overall vi if u like.
Thanks
Damien
10-10-2012 02:44 AM
Also when i run my vi it says the table name given is blank? The name of my database table is called StepResults first colunm is TestStep1 etc. Is there a solution to this?
Damien
10-10-2012 03:37 AM
I just changed the input to a constant with my table name re-run the code and an error occured.
Possible reason(s):
ADO Error: 0x80040E37
Exception occured in Microsoft JET Database Engine: Could not find output table 'TestResults'. in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->DatabaseWrite.vi