Entrambe le proprietà indicate sopra sono da impostare attraverso le AdvacedProperties dell’IOServer. Se la tabella non esiste viene create automaticamente in fase di avvio ed è strutturata nel seguente modo:
Di seguito un esempio di utilizzo dei driver IToolS SQL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace TestSqlDriver { public class Form1 : Form { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; private IToolS.Windows.Forms.Variables.VariablesWindow variablesWindow1; private IToolS.Components.IOServers.IOServer ioServer1; private IToolS.Components.Communication.Clients clients1; private IToolS.Components.Communication.Client client1; private IToolS.Components.Communication.Group group1; private IToolS.Components.Communication.Variable variable1; private IToolS.Components.Communication.Variable variable2; private IToolS.Components.Communication.Variable variable3; private IToolS.Components.Communication.Variable variable4; private IToolS.Windows.Forms.TextBox textBox1; private IToolS.Components.Communication.Variable variable5; public Form1() { InitializeComponent(); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.variablesWindow1 = new IToolS.Windows.Forms.Variables.VariablesWindow(); this.group1 = new IToolS.Components.Communication.Group(this.components); this.variable1 = new IToolS.Components.Communication.Variable(this.components); this.variable2 = new IToolS.Components.Communication.Variable(this.components); this.variable3 = new IToolS.Components.Communication.Variable(this.components); this.variable4 = new IToolS.Components.Communication.Variable(this.components); this.variable5 = new IToolS.Components.Communication.Variable(this.components); this.ioServer1 = new IToolS.Components.IOServers.IOServer(this.components); this.clients1 = new IToolS.Components.Communication.Clients(this.components); this.client1 = new IToolS.Components.Communication.Client(this.components); this.textBox1 = new IToolS.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.variablesWindow1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.group1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ioServer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.clients1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.client1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.textBox1)).BeginInit(); this.SuspendLayout(); // // variablesWindow1 // this.variablesWindow1.ColumnColor = System.Drawing.SystemColors.Control; this.variablesWindow1.EditKeyboardConfig.Font = new System.Drawing.Font("Tahoma", 8F); this.variablesWindow1.Fields = new string[] { "VariableName", "VariableType", "Area", "Address", "Value"}; this.variablesWindow1.Group = this.group1; this.variablesWindow1.KeyboardConfig.Font = new System.Drawing.Font("Tahoma", 8F); this.variablesWindow1.Location = new System.Drawing.Point(12, 12); this.variablesWindow1.Name = "variablesWindow1"; this.variablesWindow1.Size = new System.Drawing.Size(765, 380); // // group1 // this.group1.GroupName = "group1"; this.group1.Items.AddRange(new IToolS.Components.Communication.Variable[] { this.variable1, this.variable2, this.variable3, this.variable4, this.variable5}); // // variable1 // this.variable1.Address = "0"; this.variable1.VariableName = "variable1"; // // variable2 // this.variable2.Address = "2"; this.variable2.VariableName = "variable2"; this.variable2.VariableType = "String"; // // variable3 // this.variable3.Address = "100"; this.variable3.VariableName = "variable3"; // // variable4 // this.variable4.Address = "104"; this.variable4.VariableName = "variable4"; this.variable4.VariableType = "Long"; // // variable5 // this.variable5.Address = "104"; this.variable5.VariableName = "variable5"; this.variable5.VariableType = "Real"; // // ioServer1 // this.ioServer1.AdvancedProperties.Add(new IToolS.Data.Base.AdvancedProperty("ConnectionString", "Data Source=localhost\\SqlExpress;Initial Catalog=IToolS;Integrated Security=SSPI;")); this.ioServer1.Name = "SqlStore"; // // clients1 // this.clients1.ClientsName = "clients1"; this.clients1.Items.AddRange(new IToolS.Components.Communication.Client[] { this.client1}); // // client1 // this.client1.ClientName = "client1"; this.client1.Group = this.group1; this.client1.IOServer = this.ioServer1; // // textBox1 // this.textBox1.KeyboardConfig.Font = new System.Drawing.Font("Tahoma", 8F); this.textBox1.Location = new System.Drawing.Point(355, 399); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(100, 20); this.textBox1.TabIndex = 1; this.textBox1.Variable = this.variable2; this.textBox1.WriteVariableOnKeyboardEnter = true; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(789, 440); this.Controls.Add(this.textBox1); this.Controls.Add(this.variablesWindow1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.variablesWindow1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.group1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ioServer1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.clients1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.client1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.textBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } private void Form1_Load(object sender, EventArgs e) { clients1.Start(); } } } |
Lo stesso driver è disponibile anche per MySql impostando la proprietà “Name” dell’IOServer a “MySqlStore”.