01-11-2007 07:45 AM
01-11-2007 09:14 AM
You could execute a SQL command instead. This way lets the autoincrement field do its stuff automatically.
When table names have spaces in them you need to enclose them in [ ] brackets. I always avoid using names that are reserved words in SQL like Date and therefore ambiguous.
I have followed my nose and provided an example attached.
Can you try it and let me know if works?
Hope this helps
David
01-11-2007 10:50 AM
Thanks David, your VI works fine.
I should have realised that DATE would cause a problem being an SQL operator. I have also put square brackets, as you suggested around the column names in the string table I created and that now works but it still did not like the string name DATE, as expected I guess.
In your VI you have used the sub VI 'DB Free Object. Being new to the toolset, would my version without this cause problems? I think your VI is probably more flexible as you are using SQL commands rather than depending upon the pre built LV VI functions. I have got some books coming on Database design so I think a few weeks reading might be in order!!
Thanks for your help, greatly appreciated,
John
01-11-2007 12:37 PM
I can't see the code, but in general, you should definitely free references.
The LV DB toolkit communicates with the DB through ActiveX, which is an external resource, so LV can close references automatically only when you stop the top level VI. If you don't close the references, you will get a memory leak. This might not be important for something that runs for a short time, but if your app runs for a long time (as DB related apps tend to do), your application will start running slower and slower and eventually crash.
Don't underestimate the built-in functions - they also simply create SQL queries behind the scenes (you can see that if you open them), but the real magic in them is the parser which can parse the different data types and accept any data type (see the Insert Data VI for an example).