LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MS SQL and storing data on change

Solved!
Go to solution

Hi,

 

I have sql server and sql database. I use connectivity toolkit and DB tools, to open, write...on this database...

 

I want to know where can I set that will store my data only on change ? Any hint, advice?

 

thanks

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 1 of 8
(2,804 Views)

Anyone?

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 2 of 8
(2,800 Views)

Dear hlod,

 

I'm affraid, there is not a simple database VI, which implicitly checks your data, and update in database if changed, however you can do a it programmatically.

 

To achive the described functionality, you can use value polling with while loops, or event structures registred to user defined events, and in the code area you can put your database update VIs.

If you use LabVIEW DSC module as well, you can subscribe to shared variable value change events and provide your database update code in an event structure.

I found some useful example for you:

Log Value Changes of All Front Panel Controls to a File or Database

 

If you use DSC module, you can take a look on this example VI from the Example Finder:

dsc_event_structure_example.png

 

If you're looking for something else for your application, please provide more specific information about it.

 

Best Regards,

Tamas Szekely

Applications Engineer

National Instruments

 

Message 3 of 8
(2,793 Views)
Solution
Accepted by topic author hlod

The notification of database changes is dependent on the database you use, the version you use, and the specific provider you use. With SQL Server 2008 you could add triggers to tables, as discussed here: http://msdn.microsoft.com/en-us/library/bb726006.aspx. There is also the SqlDependency class (.NET).

 

Your question is really more of a database question rather than a LabVIEW question, so perhaps you will gain more traction by posting in one of the SQL forums, or by doing a search on stackoverflow.com.

 

 

Also, please be aware that you posted your message on a Sunday. This forum is primarily made up of volunteers. A little patience is appreciated.

Message 4 of 8
(2,782 Views)

Hmm, unfortunately I have SQL Server 2005; I received data via OPC client-> MS SQL server(database). I just want that from OPC server will logged into database just on change.

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 5 of 8
(2,772 Views)

Dear hlod,

I have some questions:

Do you wan't to get notification if change accoured at OPC server or in the SQL server?

Are you looking for a solution, how to program that in LabVIEW, or you are looking for if there is an option to configure OPC server for logging on data value change?

 

Best Regards,

Tamas Szekely

 

Message 6 of 8
(2,743 Views)

If you're using LV to view/edit the database as indicators/controls/tables you can use ValueChange events which only fire when an item is changed to perform an update query. If you want to follow/trigger if someone else change something in the database it wont work though, but if you only want to update the database when you change a value it can work.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 8
(2,741 Views)

Thanks to all, I use "shift register" and I think it's working...(i was only need to write in DB when appears change in input data..)

 

thanks

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 8 of 8
(2,733 Views)