...
The .NET environment offers a set of classes to access different kinds of database (MS-Access, SQL-Server, Oracle). Developing a tool that saves data from a GetValues call to a database is not difficult. The steps are as follows:
- Connect to an SQL server (Figure 1).
Figure 1 Connecting to an SQL serverCode Block // C# this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.sqlConnection1.ConnectionString = "data source=riz02\\NETSDK; " + "initial catalog=OpenMI;" + "user id=User;password=Open;" + "persist security info=True; " + "workstation id=riz02; " + "packet size=4096";
- Execute an SQL command (Figure 2).
Code Block // // SQL command Select // this.sqlSelectCommand.CommandText = " select * from measurement"; this.sqlSelectCommand.Connection=this.sqlConnection1; // // SQL command Insert // this.sqlInsertCommand.CommandText= " insert into OpenMI.measurement (Quantity, Time, Value) VALUES (QuantityID, Timestamp, Values[0]) this.sqlSelectCommand.Connection=this.sqlConnection1;
Figure 2 Executing an SQL Command
...