' Xrays2 Example ' Display Xrays in a picture box with an image index obtained ' from the database. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents txtLastName As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents txtID As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents txtFirstName As System.Windows.Forms.TextBox Friend WithEvents txtXrayID As System.Windows.Forms.TextBox Private Sub InitializeComponent() Me.txtLastName = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.txtID = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.txtXrayID = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'txtLastName ' Me.txtLastName.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtLastName.Location = New System.Drawing.Point(16, 16) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size(176, 26) Me.txtLastName.TabIndex = 0 Me.txtLastName.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(56, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(96, 24) Me.Label1.TabIndex = 1 Me.Label1.Text = "Last Name" ' 'txtID ' Me.txtID.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtID.Location = New System.Drawing.Point(16, 136) Me.txtID.Name = "txtID" Me.txtID.Size = New System.Drawing.Size(176, 26) Me.txtID.TabIndex = 2 Me.txtID.Text = "" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(56, 168) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(96, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "Patient ID" ' 'txtFirstName ' Me.txtFirstName.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtFirstName.Location = New System.Drawing.Point(16, 200) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size(176, 26) Me.txtFirstName.TabIndex = 4 Me.txtFirstName.Text = "" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(56, 240) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(96, 24) Me.Label3.TabIndex = 5 Me.Label3.Text = "First Name" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(16, 80) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(176, 32) Me.Button1.TabIndex = 8 Me.Button1.Text = "Submit" ' 'txtXrayID ' Me.txtXrayID.Location = New System.Drawing.Point(568, 136) Me.txtXrayID.Name = "txtXrayID" Me.txtXrayID.Size = New System.Drawing.Size(80, 20) Me.txtXrayID.TabIndex = 9 Me.txtXrayID.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(216, 286) Me.Controls.Add(Me.txtXrayID) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.txtFirstName) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.txtID) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtLastName) Me.Name = "Form1" Me.Text = "Xray Example" Me.ResumeLayout(False) End Sub #End Region Private conn As OleDbConnection Private cmd As OleDbCommand Private da As OleDbDataAdapter Private ds As DataSet Public xrayForm As frmXray Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load conn = New OleDbConnection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\Xrays.mdb" conn.Open() cmd = conn.CreateCommand() cmd.CommandType = CommandType.Text cmd.CommandText = "SELECT * FROM XrayTable " & _ "WHERE LastName = ''" da = New OleDbDataAdapter da.SelectCommand = cmd ds = New DataSet da.Fill(ds, "XrayTable") txtFirstName.DataBindings.Add( _ New Binding("Text", ds, "XRayTable.FirstName")) txtID.DataBindings.Add( _ New Binding("Text", ds, "XRayTable.PatientID")) txtXrayID.DataBindings.Add( _ New Binding("Text", ds, "XRayTable.XrayID")) xrayForm = New frmXray xrayForm.Hide() End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click cmd.CommandText = "SELECT * FROM XrayTable " & _ "WHERE LastName = '" & txtLastName.Text & "'" ds.Clear() Dim n As Integer = da.Fill(ds, "XrayTable") If n = 0 Then txtFirstName.Clear() txtLastName.Clear() txtLastName.Focus() Else xrayForm.Tag = txtXrayID.Text xrayForm.ShowDialog() End If End Sub End Class