LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database and SQL (datalogging)

Solved!
Go to solution

Hello all

 

I made database (see picture) to log my data.

 

database.PNG

 

Now I want to connect this database to SQL, but didn't find any example for this on forum; I read some tutorials but I'm little confused, with UDL...  Second question is where is this data stored on my PC (mdb file)

 

Thank you.

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 1 of 16
(3,463 Views)

It's unclear to me what you are asking for. The database toolkit issues SQL commands via ADO to write/read to the database you've created, it appears you are already using a UDL file, and the database file itself is where ever you created it with Access.

Message 2 of 16
(3,454 Views)

The database toolkit helps you CONNECT to a pre-existing database.  Nothing in your code "made" a database.  By using the Get UDL.vi, you simply connected to a LabVIEW example database (assuming it's set up on your PC which I think Labview does for you).

 

SQL is just the protocol language (Structured Query Language) you use to talk to a database, you don't "connect" to it.

 

The data will be stored in the database you're connected to.  Where it is, is wherever you (or your sys admin) put it.

 

A UDL (Universal Data Link) is the information file used to link programs in your computer to your database (wherever it is...).  You'll need to set up the connection using your system admin tools for ODBC.  You'll probably see the one (mdb) LabVIEW set up for you under System DSN.  See how it's configured to get an idea how to set up your own.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 3 of 16
(3,450 Views)

Hi all, yes I messed up all; I read now documentation of "Database Connectivity Toolkit", but still have some questions:

 

1. If I left "udl" in my case empty, will it save automatically to "labview.udl" ? Will overwrite it or what? I need my own database on my PC;

2. so I will use "SQL language" on "DB tools execute Query"  block ??

3. I also try to create .udl file ( I create it then choose-> Microsoft OLE DB Provider for ODBC Drivers; at connection tab I choose "Ms Access Database", wtihout password; and click OK). Then go to project as on picture up, and choose path to this .udl file; but I think nothing happend; The size of *.udl is 1KB

 

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 4 of 16
(3,446 Views)

1.  No, I think it will prompt you for a connection but connection info must be provided or it will not know what to connect to.

2.  Yes, you can send your own queries with DB Tools Execute Query.VI or use the database tools for simple storing/retrieving/etc.

3.  If you're trying to use your own database then you must create your database first, then you can set up a connection and communicate with it. 

 

Again, LabVIEW will not create your database.  You must do it yourself with MS Access or whatever.  You decide what tables go in the database, what fields are in each table, which table fields are keys, how the keys link the tables, etc.... Once you are done with that, you use LabVIEW to add, update, modify, read and delete the records in your tables.

 

If this is unclear you need to google "database tutorials" and understand the concepts before you begin.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 5 of 16
(3,439 Views)

Your code will create the table Logging in the database referred to by the UDL.

You need to install sql express, access or something similar, create a database in that and then link the UDL to that database.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 16
(3,434 Views)

Hmmm, so Labview will not create automatically "database" from my input's(for example data receiving from OPC server)? There is no other way, just to manually create database in access...?

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 7 of 16
(3,436 Views)

But if I run my .vi(as on picture) without and .udl path, everything working; but I don't know where is logging my data; maybe to labview.udl ???

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 8 of 16
(3,430 Views)

Of course it's using LabVIEW.udl. That is exactly what the help says it is doing and you can see for yourself just by looking at the block diagram. Get UDL File Path function is intended to be using with only the shipping example database.

Message 9 of 16
(3,425 Views)

Ok, then this udl is just for example...?

 

 

Then only way is to create "udl" with MS Access(this one I have installed), and then change path in .vi to this udl. After that will be logging my input to this .udl ?

 

How can I then for example show this data from this database, I just read again this .udl?

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 10 of 16
(3,422 Views)