Abstract: This article introduces the connection method between Labview and SQL Server. Keywords: LabVIEW, SQL Server, connection. Body: databases are generally used when LabVIEW is used for data collection and analysis. When the data volume is large, you can consider using SQL Server. The following describes how to connect LabVIEW to SQL Server. Connection idea: first create your own database in SQL Server, such as mydb. Then, create a data source (ODBC) in the operating system. Select SQL Server as the driver for the data source, and associate the data source with mydb in SQL Server. Finally, use ActiveX in LabVIEW to connect to the data source. This article assumes that you have created a data source labviewconsql, and the data source is associated with the database mydb, including the table tempdemo, Table Style 1: Figure 1 describes the detailed steps: 1. Connection. Place invoke node on the back panel, right-click the select calss/ActiveX/adob. _ connection attribute class, and select its messord as open. Create an automation open node and create a constant. Select adob. _ connection as the class. 2: Figure 22. After the connection is successful, create and execute the command. First, configure the command attribute, place the porperty node on the back panel, and associate the class with adob. _ command. Then select activeconnection. Process 3: Figure 33. recordset for the last table record operation. Because the program is relatively simple, I will not describe it in detail here. Example 4: Figure 4 All Programs 5: Figure 5 get the first nine records of the table after running the program, as shown in figure 6. Summary: the connection method described in this article is to use the ActiveX control at the bottom of LabVIEW to execute the ado api. To understand this article, you need to understand the ActiveX operating mechanism of LabVIEW and the programming model of ADO. With the basic ADO programming model: · connect to the data source and start a transaction. · Select an object to create an SQL command ). · You can specify columns, tables, and values as variable parameters in SQL commands ). · Execute commands (command, connection, or recordset ). · If the command returns by line, the row is stored in the cache (recordset ). · You can choose to create a cache view to sort, filter, and locate data (recordset ). · Add, delete, or modify rows and columns to edit data (recordset ). · Use the changes in the cache to update the data source (recordset) as appropriate ). · If a transaction is used, changes made during the Transaction completion can be accepted or rejected. End the transaction (connection ). References: 1. For programmers, refer to Microsoft Corporation. Microsoft ActiveX Data Objects (ADO) 2. National Instruments Corporation. LabVIEW help
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.