+ All Categories
Home > Documents > Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too...

Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too...

Date post: 06-Jun-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
33
Database Communication using LabVIEW Hans-Petter Halvorsen, M.Sc.
Transcript
Page 1: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

DatabaseCommunicationusingLabVIEW

Hans-PetterHalvorsen,M.Sc.

Page 2: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Software Software

MicrosoftSQLServerExpresscanbedownloadedforfreefromInternet

AllLabVIEWSoftwarecanbedownloadedfrom:www.ni.com/download

Page 3: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

MicrosoftSQLServerDatabase

Overview

CreateTables

DatabaseManagement

Write/ReadData

ODBC

LabVIEWApplicationwithGUIthatCommunicatewiththeSQLServer

Page 4: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

DatabaseSystems

Hans-PetterHalvorsen,M.Sc.

Page 5: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

OldfashionDatabase(Data-storage)Systems

Nottoolongago,thiswastheonlydata-storagedevicemostcompaniesneeded.Thosedaysareover.

Page 6: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

DatabaseSystems• ADatabaseisastructuredwaytostorelotsofinformation.

Theinformationisstoredindifferenttables.• - “Everything”todayisstoredindatabases!

Examples:• Bank/Accountsystems• InformationinWebpagessuchasFacebook,Wikipedia,YouTube,etc.

• …lotsofotherexamples!(Giveme5examples)

Page 7: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

DatabaseManagementSystems(DBMS)• Oracle• MySQL• MariaDB• Sybase• MicrosoftAccess• MicrosoftSQLServer• ... (wehavehundredsdifferentDBMS)

Page 8: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Hans-PetterHalvorsen,M.Sc.

SQLServer

Page 9: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

MicrosoftSQLServer Software

Page 10: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

CreatingTables

SchoolIdNameDescription

SCHOOLTableName

TableColumns

PrimaryKey

Page 11: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatetheExamplefromScratch

Page 12: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

StructuredQueryLanguageSQL

Hans-PetterHalvorsen,M.Sc.

Page 13: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

WhatisSQL?• SQL– StructuredQueryLanguage• SQLisastandardlanguageforaccessingdatabases– andmanipulatedata

• SQLisnotcasesensitive

select SchoolId, Name from SCHOOL

ColumnsTable

Example:

Weusethe“SELECT”commandinordertogetdatafromtheDatabase

Theory

Page 14: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

SQL– StructuredQueryLanguage

• insert into STUDENT (Name , Number, SchoolId)values ('John Smith', '100005', 1)

• select SchoolId, Name from SCHOOL

• select * from SCHOOL where SchoolId > 100

• update STUDENT set Name='John Wayne' where StudentId=2

• delete from STUDENT where SchoolId=3

QueryExamples:

Wehave4differentQueryTypes:INSERT,SELECT,UPDATEand DELETE

Theory

Page 15: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatesomeExamplesfromScratch

Page 16: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Hans-PetterHalvorsen,M.Sc.

OpenDatabaseConnectivity(ODBC)

Page 17: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

ODBCODBC(OpenDatabaseConnectivity)isastandardizedinterface(API)foraccessingthedatabasefromaclient.Youcanusethisstandardtocommunicatewithdatabasesfromdifferentvendors,suchasOracle,SQLServer,etc.ThedesignersofODBCaimedtomakeitindependentofprogramminglanguages,databasesystems,andoperatingsystems.ControlPanel→AdministrativeTools→DataSources(ODBC)

WewillusethisODBCConnectionlaterinLabVIEWinordertoopentheDatabaseConnectionfromLabVIEW

Theory

Note!Makesuretousethe32bit versionoftheODBCTool!

Page 18: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

ODBC– StepbyStepInstructions

18

TheNameofyourSQLServer

TheNameofyourODBCConnection

UseeitherWindowsorSQLServerauthentication(Windowsissimplesttouse!)

SelecttheDatabaseyouareusing

Testyourconnectiontoseeifitsworks

Page 19: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatetheExamplefromScratch

Page 20: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

DatabaseCommunicationinLabVIEWLabVIEW

Hans-PetterHalvorsen,M.Sc.

Page 21: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Hans-PetterHalvorsen,M.Sc.

LabVIEWSQLToolkitForEasyDatabaseCommunicationusingLabVIEW

Page 22: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LabVIEWSQLToolkit

http://home.hit.no/~hansha/documents/labview/code/SQLToolkit.zip

ForEasyDatabaseCommunicationusingLabVIEW

©Hans-PetterHalvorsenDownloadforfreehere:

SoftwareSoftware

Page 23: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LabVIEWSQLToolkit

23

Example1:GetDatafromDatabaseintoLabVIEW:

Example2:WriteDatatoDatabasefromLabVIEW:

EasyAccesstoDatabaseSystemsfromLabVIEW

YourODBCConnection

2DTablewithData

1

Query

Query

2 3

1 2 3

Students:TrytheseExamples

Page 24: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Example1:GetDatafromDatabaseintoLabVIEW

Page 25: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatetheExamplefromScratch

Page 26: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Example2:WriteDatatoDatabasefromLabVIEW

Page 27: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatetheExamplefromScratch

Page 28: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

AlternativeSolution:TypeintheConnectionStringforyourDatabase

Note!Whenusingthismethod,youdontneedtocreateanODBCConnectionfirst!

YourPasswordforthesauser

YourSQLServerInstance

TypeyourDatabasehere

YourSQLQuery

Page 29: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Hans-PetterHalvorsen,M.Sc.

LabVIEWExampleLoggingMeasurementsDatatoSQLServer

Page 30: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LoggingMeasurementDataintoSQLServerDatabase

30

TemperatureMeasurements(TC-01Thermocouple)

Note!YouwillneedtheNIDAQmxDriver

Page 31: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LoggingMeasurementDataintoSQLServerDatabase

Page 32: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

LetsCreatetheExamplefromScratch

Page 33: Database Communication using LabVIEW Video · Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies needed. Those days

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/


Recommended