Jump to content

DrSpaceMan

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by DrSpaceMan

  1. Great advice. Thanks everybody. I was able to resolve this in a very very simple way: changed my provider in my datalink. I was using the more generic OLE DB provider but switching to the more native SQL server provider resolved it. This goes hand in hand with what candidus was saying. Below is an illustration of the difference between the 2 methods of connection:
  2. I've discovered a bit more and it seems to deal with the DECLARE @<variable> statement. For example: DECLARE @FOO varchar(100) = '123456' select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE @FOO and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R' That does not work in LabVIEW or TestStand but it does work in other environments. Rewriting, the following works in LabVIEW select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE '%s' and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R' and TestStand "select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE '" + Locals.PartNumber + "' and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R' " This indicates to me that somewhere between getting the string of the SQL query and actually giving that string to the SQL Server, something was altered. I tried escaping the @ string but that didn't help. It appears on some ni.com forums that they have issues with DECLARE but I'm unsure as to the degree. (http://forums.ni.com/t5/LabVIEW/SQL-Query-Works-in-MS-SQL-Server-2008-but-not-when-using/td-p/2151492) I could use the Create Parameterized Query and Set Parameter Values VIs but that seems like a work around to translate a SQL query which typically works for use with LabVIEW. I'm trying to have one text document filled with queries that any environment can pull from.
  3. Thanks for the reply ShaunR. I had done that but it doesn't change the functionality, nor lead me anywhere. The more I use NI tools, I think it's not the string "" codes affecting it. If you take LabVIEW out of the equation and use TestStand's Database viewer tool or more simply calling Database steps (Open DB, Open SQL Statement, Data Operation, etc.), records are not returned. This leads me to believe it's something in the implementation of the NI SQL interface.
  4. Hi, I am connecting to an SQL server running 10.5. Using LabVIEW Database Connectivity toolkit and/or TestStand's Database Viewer I can successfully open a connection and run a simple query which returns the proper records. A more advanced query and no records are returned and the properties show that the state is closed. Copy and pasting this query into Microsoft SQL Server Management Studio successfully fetches the correct records. Also running this same query in python using pyodbc returns the correct record. The VI is straight forward. I attached the snippet. My first thought is that the string contains some bytes in codes that causes the query to be interpreted wrong by NI's tools. Does anybody have experience as to why a query works in other environments but not in NI's tools? Again, a simple query did work, but a more complex one did not. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.