ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing and Reading data with Database Connectivity Toolkit and SQL Server

Solved!
Go to solution

Currently I have a VI that is writing and reading information from a SQL Server (Microsoft SQL Server 2016). If I'm practically writing and

consulting information (comparing if data is written, if not, save new data) from the 4 cursors, which one is the most recommended

to use: dynamic, forward-only, key-set or static.

 

At the moment I compiled the VI using the dynamic cursor in my queries. But I'm getting some weird timeout error (258). So I want to try

changing the cursor, if maybe that could help somehow.

 

Please help me with this matter, I would really appreciate it.

 

In advance; thanks a lot everyone.

0 Kudos
Message 1 of 7
(4,760 Views)

I don't understand your question at all.  Can you give an example of what you are trying to do and post a snippet of your code?  

 

A cursor is not a required parameter to execute SQL statements.  Are you certain that you need to use cursors?  

aputman
0 Kudos
Message 2 of 7
(4,733 Views)

Here are some screenshots of my code. For example:

 

  • In that pointed subVI I check if some label is already saved in the SQL Server.
  • If not, I save the data.
  • If it is already saved, I send a pop message, telling the operator that the respective label in manner has already been previously scanned.

I have been getting some weird error, so I'm going to try changing cursors at my queries.... I have no clue if this is going to affect in some way. But before doing so, I want to know if someone here in the forums has some tips, guidance of answer to my question:

 

  • "How does it affect if I change the cursor in my queries? I'm currently using "Dynamic".

 

Do you have experience, changing cursor and knowing the main difference between them? Pros and cons?

 

 

 

Download All
0 Kudos
Message 3 of 7
(4,727 Views)

Like I said, you don't need a cursor just to select some values.  I'm not really sure how cursors work because I have never used them.  I think they allow you to scroll thru the values and see updates as they happen by other users.  Seems to me that the overhead would be high to use them. 

aputman
0 Kudos
Message 4 of 7
(4,717 Views)

Oh ok... I'm going to test changing the cursor to "forward-only", since in the HELP menu says it has the "best performance". Thanks for your

answer anyways Smiley Happy

0 Kudos
Message 5 of 7
(4,714 Views)

Forward-only appears to be the default cursor type.  That input is not required so just leave it blank unless you want to use something different. 

aputman
0 Kudos
Message 6 of 7
(4,603 Views)
Solution
Accepted by topic author JLuna

It seemed like at some point the intranet of the Company failed. The weird thing is that in the connection time out I have the default, up to 15 seconds... This didn't work, so what I did was the next logarithm:

 

1. If connection error appear while opening connection. I saved the whole query in .txt file.

2. The program kept going as normal and in the next cycle, when opening connection once again, I check if notepad has any queries:

     - If it does, gets those queries and executes them.

     - If not, opens connection and execute the current query.

3. Up to know, that has been my own solution.

 

Thanks for your support and comments anyways. I really appreciated it. By the way left the cursor as "forward only".

 

0 Kudos
Message 7 of 7
(4,564 Views)