11-08-2006 01:57 PM
11-08-2006 02:24 PM
Do you need to put the data in a specific DB or just allow the DB to access it? An application built using SQL server should be able to read a standard ASCII file.
If you do need to save it into a specific DB, then you probably need to have a table for the data (you can create it using SQL server or Access or by using an SQL command from LV) and insert that data into the table using a simple SQL command. You should be able to do this with LabSQL. Depending on the nature of your system, it might get more complicated.
If the DB exists and is managed by someone else, you should talk to them. If it doesn't, you should consider whether you need it at all, but if you do, you should start by reading some tutorials on DBs.
11-09-2006 05:07 AM
(Do you need to put the data in a specific DB or just allow the DB to access it?)
Once the file containing the saved data is closed it needs to be sent to the database which is Microsoft SQL server. It is highly unlikely that my Labview program would ever have to read the database or use any values from it as it only controls a test and calibration rig.
(An application built using SQL server should be able to read a standard ASCII file)
Does this mean I could just save my data that was created as strings (originally intended to go into a spreadsheet for analysis) to some location on my clients server and he could then recover the data and manipulate it into tables to suit his requirements?
I have had a look at some tutorials that were linked on the forum a few years ago and they were very good (simple explanations!) and described the control words used to create and access a database. But with limited knowledge I am concerned that I could end up spending considerable time trying to work with a database whilst the original control/test aspect of the project goes pear shaped!!
From your reply my solution might be straightforward?
Thanks
11-09-2006 05:50 AM
Again, the question is whether this DB already exists or whether you're expected to create a new DB.
Assuming that it already exists, talk to the person managing the DB. If they can read an ASCII file, then you can just put that file on the server and let them manage it.
If they can't, then you will need to form a connection to the database (in Control Panel>>Administrative Tools>>ODBC Data Sources) and insert the data into a table. You should probably define a specific table just for that and simply push your data into that table.
11-09-2006 07:58 AM
11-09-2006 08:47 AM
11-09-2006 09:14 AM
Pity the poor IS person who actually has to do some support.
It may be more work for him but that's what he is there for and it sounds like it's his company that wants the test data integrated into the database. You could probably leave a lot of the details up to him and let him decide on the basic design. He will need to contact the users and find out how they wish to use the data. For example, your test results may need to link to shipping. Besides the test results, you might also need to store the serial number. The date/time of the test is usually a requirement as well. The IS person is (or should be) capable of writing a stored procedure that makes it a bit easier for you as well. A stored procedure is basically a program that will accept parameters and do all of the low level database commands for you.
Since the database is at the client's and you may not have access at all times, you might want to consider setting up a local MS Access database with a simple table that would save just your results. This would allow you to get familiar with either the database toolkit or LaBSQL and do all of the debug locally. When it's time to install the program at the client, you just have to change the name of the database server and this can be done externanly from LabVIEW in a .udl file or from the windows ODBC administrator.
12-28-2006 08:56 AM
12-29-2006 04:01 AM
I'm having trouble understanding exactly what you're doing, but I will try to explain a few things:
Ideally code written for database connectivity should not be included in my Labview code or problems could occur if my client changed his servers , database structure etc.
The code can be yours. If you do write it, just make sure to create subVIs, so that if the DB structure does change (something which is rare), you will only need to change the code inside the subVIs.
Microsoft SQL server is an intermediate piece of software that allows my Labview code to access the database without actually 'seeing' it. With my client using SQL server they can modify the way my Labview code sends data to their database if they decide to change their servers, database structure etc.
SQL Server is the DB management system. It holds all the tables, queries, etc. and is responsible for actually managing the DB itself.
What Dennis suggested was that the DB guy will write something known as a "stored procedure" and that you will call it.
In such a case, if the DB guy wanted to change something, he could just change the stored procedure and (if the change does not affect the interface), you do not have to change or rebuild your program. This is equivalent to the subVIs I described earlier, except in this case, the function is inside the DB itself.
Another version of this is creating a table with SQL commands and assigning a name for each command. You load the SQL command from the table by name and execute it. This allows for changing the SQL command inside the DB without changing your application.
ADO connectivity is used and the connection string is best located in the windows registry file. Presumably this option would give my client the most flexiblity? Is this the same thing as the .udl file?
Basically, the scheme is like this:
DB <-> DBMS <-> ODBC <-> ADO <-> Your Application
This may not be perfectly accurate, but the concept is basically this - in Windows, you talk to ANY database from ANY program using the same interface - you call ADO functions which will be responsible for getting to the DB you want and you use SQL to issue the commands, since the basic SQL commands are supported by all DBs.
To identify the DB, you use a connection string. This connection string can have all the data in it or it can point to an existing file (UDL or DSN) which holds the data pointing to the DB. Dennis suggested that when developing on your machine, you will use a file pointing to a local DB, but when deploying you will use a file of the same name which will point to the real DB. Your program will always go to the file and from there it will know which DB to go to.
The only time when this should really matter to the client is during configuration (for example, if the DB was moved to a different machine). All the client needs to do is edit the UDL file to point at the new location of the DB.
Again, the advantage of all this is that this is not part of your code and is done by programs which are built to handle it.
It is more efficient to use the Parameterized database technique such as the example given in the 'logging example parameterized'
I have sent my client an outline of the data to be saved on their database, which at the moment comprises of 3 tables, the first has things like operators name, date, time, serial number etc ( 7 records, 3 fields) the second table has test reference (11 tests in total) with items such as fuel flow, fuel temp etc (11 records, 5 fields), Last table has 1 record and 6 fields. Unlike the Labview example each stage of the test can take up to 4 minutes to complete and if successfull the program moves on to the next stage of the test, saving the test results and if a PASS or FAIL occurred. The question I have is would it more efficient to save the results at the end of all of the tests or shold I connect to their database and save results as the tests progress?
I can't say I understand this, but my suggestion would be to let the client decide in what format they want the data, since they're the ones who want it. Work with the DB guy to decide exactly what data you need to put into the DB and where and then you can decide exactly which functions you need. As said, you might want to let the DB guy write some stored procedures which you can use to input the data.
Unless it's a large amount of data, writing to a DB is usually fairly quick (under a second). If it is relevant, my suggestion would be to write after each phase.
In any case, I suggest you go through some real DB tutorials (not LV related) and see if you can wrap your head about it. I know I don't particularly like designing DBs (or PID) any more than you do, but it's a skill worth having, and in some places, a DB makes things easy and practical.
01-03-2007 11:01 AM