* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Database Communication in LabVIEW
Serializability wikipedia , lookup
Tandem Computers wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Microsoft Access wikipedia , lookup
Oracle Database wikipedia , lookup
Functional Database Model wikipedia , lookup
Ingres (database) wikipedia , lookup
Concurrency control wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
ContactPoint wikipedia , lookup
Relational model wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Clusterpoint wikipedia , lookup
DatabaseCommunication
usingLabVIEW
Hans-PetterHalvorsen,M.Sc.
Software
MicrosoftSQLServerExpresscanbe
downloadedforfreefromInternet
Software
AllLabVIEWSoftwarecanbedownloaded
from:www.ni.com/download
Overview
Microsoft
SQLServer
Database
ODBC
Write/ReadData
DatabaseManagement
CreateTables
LabVIEWApplicationwithGUIthat
CommunicatewiththeSQLServer
DatabaseSystems
Hans-PetterHalvorsen,M.Sc.
OldfashionDatabase(Data-storage)Systems
Nottoolongago,thiswastheonlydata-storagedevicemost
companiesneeded.Thosedaysareover.
DatabaseSystems
• ADatabaseisastructuredwaytostorelotsofinformation.
Theinformationisstoredindifferenttables.
• - “Everything”todayisstoredindatabases!
Examples:
• Bank/Accountsystems
• InformationinWebpagessuchasFacebook,Wikipedia,
YouTube,etc.
• …lotsofotherexamples!(Giveme5examples)
DatabaseManagementSystems(DBMS)
•
•
•
•
•
•
•
Oracle
MySQL
MariaDB
Sybase
MicrosoftAccess
MicrosoftSQLServer
... (wehavehundredsdifferentDBMS)
SQLServer
Hans-PetterHalvorsen,M.Sc.
MicrosoftSQLServer
Software
CreatingTables
TableColumns
SCHOOL
SchoolId
Name
Description
TableName
PrimaryKey
LetsCreatetheExamplefromScratch
SQL
StructuredQueryLanguage
Hans-PetterHalvorsen,M.Sc.
WhatisSQL?
Theory
• SQL– StructuredQueryLanguage
• SQLisastandardlanguageforaccessing
databases– andmanipulatedata
• SQLisnotcasesensitive
Example:
select SchoolId, Name from SCHOOL
Weusethe“SELECT”commandinorder
togetdatafromtheDatabase
Columns
Table
SQL– StructuredQueryLanguage
Theory
QueryExamples:
• 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
Wehave4differentQueryTypes:INSERT,SELECT,UPDATEand DELETE
LetsCreatesomeExamplesfromScratch
OpenDatabaseConnectivity
(ODBC)
Hans-PetterHalvorsen,M.Sc.
ODBC
ODBC(OpenDatabaseConnectivity)isastandardizedinterface(API)foraccessing
Theory
thedatabasefromaclient.Youcanusethisstandardtocommunicatewith
databasesfromdifferentvendors,suchasOracle,SQLServer,etc.Thedesigners
ofODBCaimedtomakeitindependentofprogramminglanguages,database
systems,andoperatingsystems.
ControlPanel→AdministrativeTools→DataSources(ODBC)
WewillusethisODBCConnectionlater
inLabVIEWinordertoopenthe
DatabaseConnectionfromLabVIEW
Note!Makesuretousethe32
bit versionoftheODBCTool!
ODBC– StepbyStepInstructions
TheNameofyour
ODBCConnection
TheNameofyour
SQLServer
SelecttheDatabase
youareusing
UseeitherWindows
orSQLServer
authentication
(Windowsissimplest
touse!)
Testyour
connectiontosee
ifitsworks
18
LetsCreatetheExamplefromScratch
LabVIEW
DatabaseCommunicationinLabVIEW
Hans-PetterHalvorsen,M.Sc.
LabVIEWSQLToolkit
ForEasyDatabaseCommunicationusingLabVIEW
Hans-PetterHalvorsen,M.Sc.
LabVIEWSQLToolkit
Software
Software
ForEasyDatabaseCommunicationusingLabVIEW
©Hans-PetterHalvorsen
Downloadforfreehere:
http://home.hit.no/~hansha/documents/labview/code/SQLToolkit.zip
LabVIEWSQLToolkit
EasyAccesstoDatabaseSystemsfrom
LabVIEW
2DTablewithData
Example1:GetDatafromDatabaseintoLabVIEW:
1
3
2
Query
YourODBC
Connection
Example2:WriteDatatoDatabasefromLabVIEW:
Query
1
Students:TrytheseExamples
2
3
23
Example1:GetDatafromDatabase
intoLabVIEW
LetsCreatetheExamplefromScratch
Example2:WriteDatatoDatabase
fromLabVIEW
LetsCreatetheExamplefromScratch
AlternativeSolution:Typeinthe
ConnectionStringforyourDatabase
YourPasswordforthesauser
TypeyourDatabasehere
YourSQLServerInstance
YourSQLQuery
Note!Whenusingthismethod,youdontneedtocreateanODBCConnectionfirst!
LabVIEWExample
LoggingMeasurementsDatatoSQLServer
Hans-PetterHalvorsen,M.Sc.
LoggingMeasurementDatainto
SQLServerDatabase
TemperatureMeasurements(TC-01Thermocouple)
Note!YouwillneedtheNIDAQmxDriver
30
LoggingMeasurementDatainto
SQLServerDatabase
LetsCreatetheExamplefromScratch
Hans-PetterHalvorsen,M.Sc.
UniversityCollegeofSoutheastNorway
www.usn.no
E-mail:[email protected]
Blog:http://home.hit.no/~hansha/