|
Prev: Database
Next: LabVIEW reading LPT under Windows XP
From: Gurdas on 10 Aug 2005 12:10 Hi, How can I pass NULL values when using the Parameterised SQL Query (or stored procedure) method to write values into my SQL server database? The problem can be simulated using the "Insert Example.vi" shipped with the Database Connectivity Toolset (ver 1.0, May 2001).LV allows for NULL when using "SQL Query" but gives an error when using "Parameterised SQL Query".In this example, the error occurs when the "device name" string field is set to blank (not even a single white space). I am using LV 7.1 FDS and Database Toolkit ver 1.0 on Win 2000 Thanks,Gurdas
From: Philip C. on 11 Aug 2005 20:41 Hi Gurdas, This behavior has previously been reported to the LabVIEW developers. Here is the reason that you get an error with the Parameterized Query: There is a big difference between executing an SQL statement and doing a Parameterized Query, especially when looking at the low-level ADO layer. For example, you use many different methods and properties of the ADO objects in respect to the Command object. When doing Parameterized Queries, you MUST specify all parameter values - leaving them empty results in ADO trapping errors rather than using a default (or NULL) value. Since this is defined by ADO as an error, there is nothing to do about it from the LV layer. You should continue to use SQL statements rather than parameterized queries. Gurdas, I hope you can live with this solution...
From: Gurdas on 15 Aug 2005 11:10 Hello Phillip, Your answer explains what (and why) happens if I pass an 'empty' parameter value. However that does not fully answer my question, which I have rephrased below: I want to know how to pass NULL values because if I do that, I can continue to use parameterised query (something which I HAVE to do since SQL query cannot handle the said tasks). In VB, saying NULL (and not 'NULL') tells the compiler that it has to pass null values and not the word null - and this works for parameterised query too. I want to know if LV has something similar. Hope I have been able to clearly state my question. Thanks, Gurdas
From: Philip C. on 17 Aug 2005 01:10 Hi Gurdas, Well, the reason that I can't give you a solution is because there currently isn't one available to pass NULL values to a DB using the Parameterized Query VIs. Has anyone gotten around this limitation in any way, while still using Patameterized Querys?
From: Maximus43 on 17 Aug 2005 06:10
Can you store NULL-values in that specific column? Than you should change your query, so that column is not mentiod e.g Your table1: col1, col2 and col3 col3 can store null-values If you want to insert null in col3 insert: insert into table1(col1, col2)values(?, ?) |