Error filling datagrid

catbollu

Member
Joined
Dec 15, 2004
Messages
5
Programming Experience
1-3
I am getting error= connot create a child list fo field patient.
This is a windows ap using vb.net
<code>
Inherits System.Windows.Forms.Form

' intialize variables

Dim Up As New OleDb.OleDbCommand

Dim Con As New OleDb.OleDbConnection

Dim Read As New OleDb.OleDbDataAdapter

Dim patients As New DataSet

Dim Plus As Integer

#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 PatientGrid As System.Windows.Forms.DataGrid

Friend WithEvents Label1 As System.Windows.Forms.Label

Friend WithEvents CartNumLbl As System.Windows.Forms.Label

Friend WithEvents Label2 As System.Windows.Forms.Label

Friend WithEvents Label3 As System.Windows.Forms.Label

Friend WithEvents Label4 As System.Windows.Forms.Label

Friend WithEvents timelbl As System.Windows.Forms.Label

Friend WithEvents CartNumCBx As System.Windows.Forms.ComboBox

Friend WithEvents HallCBx As System.Windows.Forms.ComboBox

Friend WithEvents SubmitCartInfoBT As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()

Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Main))

Me.PatientGrid = New System.Windows.Forms.DataGrid

Me.Label1 = New System.Windows.Forms.Label

Me.CartNumLbl = New System.Windows.Forms.Label

Me.SubmitCartInfoBT = New System.Windows.Forms.Button

Me.Label2 = New System.Windows.Forms.Label

Me.Label3 = New System.Windows.Forms.Label

Me.Label4 = New System.Windows.Forms.Label

Me.timelbl = New System.Windows.Forms.Label

Me.CartNumCBx = New System.Windows.Forms.ComboBox

Me.HallCBx = New System.Windows.Forms.ComboBox

CType(Me.PatientGrid, System.ComponentModel.ISupportInitialize).BeginInit()

Me.SuspendLayout()

'

'PatientGrid

'

Me.PatientGrid.DataMember = ""

Me.PatientGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText

Me.PatientGrid.Location = New System.Drawing.Point(8, 152)

Me.PatientGrid.Name = "PatientGrid"

Me.PatientGrid.Size = New System.Drawing.Size(496, 224)

Me.PatientGrid.TabIndex = 0

'

'Label1

'

Me.Label1.Location = New System.Drawing.Point(184, 76)

Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(48, 16)

Me.Label1.TabIndex = 1

Me.Label1.Text = "Cart Hall"

'

'CartNumLbl

'

Me.CartNumLbl.Location = New System.Drawing.Point(8, 76)

Me.CartNumLbl.Name = "CartNumLbl"

Me.CartNumLbl.Size = New System.Drawing.Size(72, 16)

Me.CartNumLbl.TabIndex = 3

Me.CartNumLbl.Text = "Cart Number"

'

'SubmitCartInfoBT

'

Me.SubmitCartInfoBT.Location = New System.Drawing.Point(240, 104)

Me.SubmitCartInfoBT.Name = "SubmitCartInfoBT"

Me.SubmitCartInfoBT.Size = New System.Drawing.Size(80, 24)

Me.SubmitCartInfoBT.TabIndex = 5

Me.SubmitCartInfoBT.Text = "Submit"

'

'Label2

'

Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.Label2.Location = New System.Drawing.Point(8, 8)

Me.Label2.Name = "Label2"

Me.Label2.Size = New System.Drawing.Size(104, 24)

Me.Label2.TabIndex = 6

Me.Label2.Text = "Patient List"

'

'Label3

'

Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.Label3.Location = New System.Drawing.Point(8, 40)

Me.Label3.Name = "Label3"

Me.Label3.Size = New System.Drawing.Size(248, 24)

Me.Label3.TabIndex = 7

Me.Label3.Text = "Enter Cart Number and Hall Name"

'

'Label4

'

Me.Label4.Location = New System.Drawing.Point(8, 104)

Me.Label4.Name = "Label4"

Me.Label4.Size = New System.Drawing.Size(32, 16)

Me.Label4.TabIndex = 8

Me.Label4.Text = "Time "

'

'timelbl

'

Me.timelbl.Location = New System.Drawing.Point(40, 104)

Me.timelbl.Name = "timelbl"

Me.timelbl.Size = New System.Drawing.Size(72, 16)

Me.timelbl.TabIndex = 9

'

'CartNumCBx

'

Me.CartNumCBx.Location = New System.Drawing.Point(80, 72)

Me.CartNumCBx.Name = "CartNumCBx"

Me.CartNumCBx.Size = New System.Drawing.Size(104, 21)

Me.CartNumCBx.TabIndex = 10

'

'HallCBx

'

Me.HallCBx.Location = New System.Drawing.Point(232, 72)

Me.HallCBx.Name = "HallCBx"

Me.HallCBx.Size = New System.Drawing.Size(128, 21)

Me.HallCBx.TabIndex = 11

'

'Main

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.BackColor = System.Drawing.Color.LightSteelBlue

Me.ClientSize = New System.Drawing.Size(512, 381)

Me.Controls.Add(Me.HallCBx)

Me.Controls.Add(Me.CartNumCBx)

Me.Controls.Add(Me.timelbl)

Me.Controls.Add(Me.Label4)

Me.Controls.Add(Me.Label3)

Me.Controls.Add(Me.Label2)

Me.Controls.Add(Me.SubmitCartInfoBT)

Me.Controls.Add(Me.CartNumLbl)

Me.Controls.Add(Me.Label1)

Me.Controls.Add(Me.PatientGrid)

Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)

Me.Name = "Main"

Me.Text = "Main"

CType(Me.PatientGrid, System.ComponentModel.ISupportInitialize).EndInit()

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitCartInfoBT.Click

'set up and intialize parameters for use in select statement

Up.Parameters.Add("Hall", Data.OleDb.OleDbType.Variant)

Up.Parameters("Hall").Value = HallCBx.Text

' open connection

Try

Con.Open()

' go to function to read data into datagrid

LoadPatientGrid()

'close connection

Con.Close()

Catch Ex As Exception

'give me a message if an error occurs

MsgBox("Error=" & Ex.Message)

End Try











End Sub

Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Connection string

Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "AmerChart.mdb;Mode=ReadWrite;Persist Security Info=False"

Up.Connection = Con

Up.CommandType = CommandType.Text

Up.CommandText = "Select * From [Patient] where Hall=@Hall;"

CartNumCBx.Text = VariableModule1.Cart

Read.TableMappings.Add("Table", "Patients")

Read.SelectCommand = Up

'get time

Dim MyTime As DateTime = DateTime.Now()

MyTime = Format(MyTime, "hh:mm:ss tt")
' Returns "05:04:23 PM".

timelbl.Text = MyTime

End Sub

Public Function LoadPatientGrid()

Read.Fill(patients)

PatientGrid.SetDataBinding(patients, "patient")

'PatientGrid.Visible = True

'Show grid and patient info

End Function



End
Class
</code>
 
Top Bottom