This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dev:odbc:sample_net [2015/01/28 01:53] doc |
dev:odbc:sample_net [2016/06/28 22:38] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
====== Development: ODBC Interface ====== | ====== Development: ODBC Interface ====== | ||
- | [[dev:odbc:home|Overview]] | [[dev:odbc:datasources|ODBC Datasources]] | [[dev:odbc:sample_c|Sample C# Program]] | **[[dev:odbc:sample_net|Sample .NET Program]]** | + | [[dev:odbc:home|Overview]] | [[dev:odbc:datasources|ODBC Datasources]] | [[dev:odbc:sample_c|Sample C# .NET Console Program]] | **[[dev:odbc:sample_net|Sample C# .NET Windows Program]]** |
---- | ---- | ||
- | ===== Sample .NET Program ===== | + | ===== Sample C# .NET Windows Program ===== |
- | The following is a very simple .NET program that shows a basic connection to an Omnidex Environment and simple query processing. | + | The following is a very simple C# .NET Windows program that shows a basic connection to an Omnidex Environment and simple query processing. |
<code csharp> | <code csharp> | ||
Line 161: | Line 161: | ||
</code> | </code> | ||
+ | The following designer provides the source code for the form referenced in the program above. | ||
+ | |||
+ | <code csharp> | ||
+ | namespace OdxOdbcNetDemo | ||
+ | { | ||
+ | partial class MainForm | ||
+ | { | ||
+ | /// <summary> | ||
+ | /// Required designer variable. | ||
+ | /// </summary> | ||
+ | private System.ComponentModel.IContainer components = null; | ||
+ | |||
+ | /// <summary> | ||
+ | /// Clean up any resources being used. | ||
+ | /// </summary> | ||
+ | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | ||
+ | protected override void Dispose(bool disposing) | ||
+ | { | ||
+ | if (disposing && (components != null)) | ||
+ | { | ||
+ | components.Dispose(); | ||
+ | } | ||
+ | base.Dispose(disposing); | ||
+ | } | ||
+ | |||
+ | #region Windows Form Designer generated code | ||
+ | |||
+ | /// <summary> | ||
+ | /// Required method for Designer support - do not modify | ||
+ | /// the contents of this method with the code editor. | ||
+ | /// </summary> | ||
+ | private void InitializeComponent() | ||
+ | { | ||
+ | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); | ||
+ | this.label2 = new System.Windows.Forms.Label(); | ||
+ | this.tbSQL = new System.Windows.Forms.TextBox(); | ||
+ | this.label3 = new System.Windows.Forms.Label(); | ||
+ | this.dgvResult = new System.Windows.Forms.DataGridView(); | ||
+ | this.buttonConnect = new System.Windows.Forms.Button(); | ||
+ | this.buttonExecute = new System.Windows.Forms.Button(); | ||
+ | this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); | ||
+ | this.label1 = new System.Windows.Forms.Label(); | ||
+ | this.tbEnvironment = new System.Windows.Forms.TextBox(); | ||
+ | this.label4 = new System.Windows.Forms.Label(); | ||
+ | this.tbHost = new System.Windows.Forms.TextBox(); | ||
+ | this.label5 = new System.Windows.Forms.Label(); | ||
+ | this.tbPort = new System.Windows.Forms.TextBox(); | ||
+ | this.tableLayoutPanel1.SuspendLayout(); | ||
+ | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit(); | ||
+ | this.tableLayoutPanel2.SuspendLayout(); | ||
+ | this.SuspendLayout(); | ||
+ | // | ||
+ | // tableLayoutPanel1 | ||
+ | // | ||
+ | this.tableLayoutPanel1.ColumnCount = 3; | ||
+ | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel1.ColumnStyles.Add(new | ||
+ | System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); | ||
+ | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.tbSQL, 0, 2); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.label3, 0, 3); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.dgvResult, 0, 4); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.buttonConnect, 2, 0); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.buttonExecute, 2, 2); | ||
+ | this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0); | ||
+ | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); | ||
+ | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; | ||
+ | this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10); | ||
+ | this.tableLayoutPanel1.RowCount = 5; | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new | ||
+ | System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new | ||
+ | System.Windows.Forms.RowStyle()); | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new | ||
+ | System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F)); | ||
+ | this.tableLayoutPanel1.RowStyles.Add(new | ||
+ | System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); | ||
+ | this.tableLayoutPanel1.Size = new System.Drawing.Size(630, 424); | ||
+ | this.tableLayoutPanel1.TabIndex = 0; | ||
+ | // | ||
+ | // label2 | ||
+ | // | ||
+ | this.label2.AutoSize = true; | ||
+ | this.label2.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.label2.Location = new System.Drawing.Point(13, 41); | ||
+ | this.label2.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); | ||
+ | this.label2.Name = "label2"; | ||
+ | this.label2.Size = new System.Drawing.Size(82, 13); | ||
+ | this.label2.TabIndex = 1; | ||
+ | this.label2.Text = "SQL Statement:"; | ||
+ | // | ||
+ | // tbSQL | ||
+ | // | ||
+ | this.tableLayoutPanel1.SetColumnSpan(this.tbSQL, 2); | ||
+ | this.tbSQL.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.tbSQL.Location = new System.Drawing.Point(13, 57); | ||
+ | this.tbSQL.Multiline = true; | ||
+ | this.tbSQL.Name = "tbSQL"; | ||
+ | this.tbSQL.Size = new System.Drawing.Size(518, 130); | ||
+ | this.tbSQL.TabIndex = 2; | ||
+ | // | ||
+ | // label3 | ||
+ | // | ||
+ | this.label3.AutoSize = true; | ||
+ | this.label3.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.label3.Location = new System.Drawing.Point(13, 195); | ||
+ | this.label3.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); | ||
+ | this.label3.Name = "label3"; | ||
+ | this.label3.Size = new System.Drawing.Size(82, 13); | ||
+ | this.label3.TabIndex = 3; | ||
+ | this.label3.Text = "Result:"; | ||
+ | // | ||
+ | // dgvResult | ||
+ | // | ||
+ | this.dgvResult.AllowUserToAddRows = false; | ||
+ | this.dgvResult.AllowUserToDeleteRows = false; | ||
+ | this.dgvResult.AllowUserToOrderColumns = true; | ||
+ | this.dgvResult.BackgroundColor = System.Drawing.Color.White; | ||
+ | this.dgvResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; | ||
+ | this.dgvResult.ColumnHeadersHeightSizeMode = | ||
+ | System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; | ||
+ | this.tableLayoutPanel1.SetColumnSpan(this.dgvResult, 3); | ||
+ | this.dgvResult.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.dgvResult.Location = new System.Drawing.Point(13, 211); | ||
+ | this.dgvResult.MultiSelect = false; | ||
+ | this.dgvResult.Name = "dgvResult"; | ||
+ | this.dgvResult.ReadOnly = true; | ||
+ | this.dgvResult.RowHeadersVisible = false; | ||
+ | this.dgvResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; | ||
+ | this.dgvResult.Size = new System.Drawing.Size(604, 200); | ||
+ | this.dgvResult.TabIndex = 4; | ||
+ | // | ||
+ | // buttonConnect | ||
+ | // | ||
+ | this.buttonConnect.Location = new System.Drawing.Point(537, 10); | ||
+ | this.buttonConnect.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); | ||
+ | this.buttonConnect.Name = "buttonConnect"; | ||
+ | this.buttonConnect.Size = new System.Drawing.Size(75, 23); | ||
+ | this.buttonConnect.TabIndex = 5; | ||
+ | this.buttonConnect.Text = "Connect"; | ||
+ | this.buttonConnect.UseVisualStyleBackColor = true; | ||
+ | this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click); | ||
+ | // | ||
+ | // buttonExecute | ||
+ | // | ||
+ | this.buttonExecute.AutoSize = true; | ||
+ | this.buttonExecute.Location = new System.Drawing.Point(537, 57); | ||
+ | this.buttonExecute.Name = "buttonExecute"; | ||
+ | this.buttonExecute.Size = new System.Drawing.Size(80, 23); | ||
+ | this.buttonExecute.TabIndex = 6; | ||
+ | this.buttonExecute.Text = "Execute SQL"; | ||
+ | this.buttonExecute.UseVisualStyleBackColor = true; | ||
+ | this.buttonExecute.Click += new System.EventHandler(this.buttonExecute_Click); | ||
+ | // | ||
+ | // tableLayoutPanel2 | ||
+ | // | ||
+ | this.tableLayoutPanel2.AutoSize = true; | ||
+ | this.tableLayoutPanel2.ColumnCount = 6; | ||
+ | this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 2); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new | ||
+ | System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.label1, 0, 0); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.tbEnvironment, 1, 0); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.label4, 2, 0); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.tbHost, 3, 0); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.label5, 4, 0); | ||
+ | this.tableLayoutPanel2.Controls.Add(this.tbPort, 5, 0); | ||
+ | this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.tableLayoutPanel2.Location = new System.Drawing.Point(10, 10); | ||
+ | this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); | ||
+ | this.tableLayoutPanel2.Name = "tableLayoutPanel2"; | ||
+ | this.tableLayoutPanel2.RowCount = 1; | ||
+ | this.tableLayoutPanel2.RowStyles.Add(new | ||
+ | System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); | ||
+ | this.tableLayoutPanel2.Size = new System.Drawing.Size(524, 26); | ||
+ | this.tableLayoutPanel2.TabIndex = 0; | ||
+ | // | ||
+ | // label1 | ||
+ | // | ||
+ | this.label1.AutoSize = true; | ||
+ | this.label1.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.label1.Location = new System.Drawing.Point(3, 0); | ||
+ | this.label1.Name = "label1"; | ||
+ | this.label1.Size = new System.Drawing.Size(88, 26); | ||
+ | this.label1.TabIndex = 0; | ||
+ | this.label1.Text = "Environment File:"; | ||
+ | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; | ||
+ | // | ||
+ | // tbEnvironment | ||
+ | // | ||
+ | this.tbEnvironment.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; | ||
+ | this.tbEnvironment.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystem; | ||
+ | this.tbEnvironment.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.tbEnvironment.Location = new System.Drawing.Point(97, 3); | ||
+ | this.tbEnvironment.Name = "tbEnvironment"; | ||
+ | this.tbEnvironment.Size = new System.Drawing.Size(189, 20); | ||
+ | this.tbEnvironment.TabIndex = 1; | ||
+ | // | ||
+ | // label4 | ||
+ | // | ||
+ | this.label4.AutoSize = true; | ||
+ | this.label4.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.label4.Location = new System.Drawing.Point(292, 0); | ||
+ | this.label4.Name = "label4"; | ||
+ | this.label4.Size = new System.Drawing.Size(32, 26); | ||
+ | this.label4.TabIndex = 2; | ||
+ | this.label4.Text = "Host:"; | ||
+ | this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; | ||
+ | // | ||
+ | // tbHost | ||
+ | // | ||
+ | this.tbHost.Location = new System.Drawing.Point(330, 3); | ||
+ | this.tbHost.Name = "tbHost"; | ||
+ | this.tbHost.Size = new System.Drawing.Size(100, 20); | ||
+ | this.tbHost.TabIndex = 3; | ||
+ | // | ||
+ | // label5 | ||
+ | // | ||
+ | this.label5.AutoSize = true; | ||
+ | this.label5.Dock = System.Windows.Forms.DockStyle.Fill; | ||
+ | this.label5.Location = new System.Drawing.Point(436, 0); | ||
+ | this.label5.Name = "label5"; | ||
+ | this.label5.Size = new System.Drawing.Size(29, 26); | ||
+ | this.label5.TabIndex = 4; | ||
+ | this.label5.Text = "Port:"; | ||
+ | this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; | ||
+ | // | ||
+ | // tbPort | ||
+ | // | ||
+ | this.tbPort.Location = new System.Drawing.Point(471, 3); | ||
+ | this.tbPort.Name = "tbPort"; | ||
+ | this.tbPort.Size = new System.Drawing.Size(50, 20); | ||
+ | this.tbPort.TabIndex = 5; | ||
+ | // | ||
+ | // MainForm | ||
+ | // | ||
+ | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | ||
+ | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | ||
+ | this.ClientSize = new System.Drawing.Size(630, 424); | ||
+ | this.Controls.Add(this.tableLayoutPanel1); | ||
+ | this.Name = "MainForm"; | ||
+ | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; | ||
+ | this.Text = "SQL Window"; | ||
+ | this.FormClosing += new | ||
+ | System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); | ||
+ | this.tableLayoutPanel1.ResumeLayout(false); | ||
+ | this.tableLayoutPanel1.PerformLayout(); | ||
+ | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit(); | ||
+ | this.tableLayoutPanel2.ResumeLayout(false); | ||
+ | this.tableLayoutPanel2.PerformLayout(); | ||
+ | this.ResumeLayout(false); | ||
+ | |||
+ | } | ||
+ | |||
+ | #endregion | ||
+ | |||
+ | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; | ||
+ | private System.Windows.Forms.Label label2; | ||
+ | private System.Windows.Forms.TextBox tbSQL; | ||
+ | private System.Windows.Forms.Label label3; | ||
+ | private System.Windows.Forms.DataGridView dgvResult; | ||
+ | private System.Windows.Forms.Button buttonConnect; | ||
+ | private System.Windows.Forms.Button buttonExecute; | ||
+ | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; | ||
+ | private System.Windows.Forms.Label label1; | ||
+ | private System.Windows.Forms.TextBox tbEnvironment; | ||
+ | private System.Windows.Forms.Label label4; | ||
+ | private System.Windows.Forms.TextBox tbHost; | ||
+ | private System.Windows.Forms.Label label5; | ||
+ | private System.Windows.Forms.TextBox tbPort; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </code> | ||
===== ===== | ===== ===== | ||
- | **[[dev:odbc:datasources|Prev]]** | + | **[[dev:odbc:sample_c|Prev]]** |
====== Additional Resources ====== | ====== Additional Resources ====== |