Hi,
I receive the error "Cannot bind to the property or column LastName on the DataSource" when I try to load the form "frmMake Booking and I can not find where the error is occurring.
frmMakeBooking DesignerCode
Also, Warning: The variable 'productsBS' is either undeclared or was never assigned. frmMakeBooking.Designer.vb Lines 150 & 166
frmMakeBooking code
Thanks,
Nightwalker
I receive the error "Cannot bind to the property or column LastName on the DataSource" when I try to load the form "frmMake Booking and I can not find where the error is occurring.
frmMakeBooking DesignerCode
vb.net Code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class frmMakeBooking Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try 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. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Dim lastNameLabel As System.Windows.Forms.Label Dim firstNameLabel As System.Windows.Forms.Label Dim titleLabel As System.Windows.Forms.Label Me.customersBindingSource = New System.Windows.Forms.BindingSource(Me.components) Me.customersBindingSource1 = New System.Windows.Forms.BindingSource(Me.components) Me.videostoreDataSetBindingSource = New System.Windows.Forms.BindingSource(Me.components) Me.customersBindingSource2 = New System.Windows.Forms.BindingSource(Me.components) Me.txtLastName = New System.Windows.Forms.TextBox Me.groupBox2 = New System.Windows.Forms.GroupBox Me.txtFirstName = New System.Windows.Forms.TextBox Me.tpBookDate = New System.Windows.Forms.DateTimePicker Me.cboCustomer = New System.Windows.Forms.ComboBox Me.cboProduct = New System.Windows.Forms.ComboBox Me.movieBindingSource = New System.Windows.Forms.BindingSource(Me.components) Me.groupBox1 = New System.Windows.Forms.GroupBox Me.txtTitle = New System.Windows.Forms.TextBox Me.cmdCheckout = New System.Windows.Forms.Button lastNameLabel = New System.Windows.Forms.Label firstNameLabel = New System.Windows.Forms.Label titleLabel = New System.Windows.Forms.Label CType(Me.customersBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.customersBindingSource1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.videostoreDataSetBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.customersBindingSource2, System.ComponentModel.ISupportInitialize).BeginInit() Me.groupBox2.SuspendLayout() CType(Me.movieBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() Me.groupBox1.SuspendLayout() Me.SuspendLayout() ' 'lastNameLabel ' lastNameLabel.AutoSize = True lastNameLabel.Location = New System.Drawing.Point(11, 87) lastNameLabel.Name = "lastNameLabel" lastNameLabel.Size = New System.Drawing.Size(61, 13) lastNameLabel.TabIndex = 18 lastNameLabel.Text = "Last Name:" ' 'firstNameLabel ' firstNameLabel.AutoSize = True firstNameLabel.Location = New System.Drawing.Point(12, 49) firstNameLabel.Name = "firstNameLabel" firstNameLabel.Size = New System.Drawing.Size(60, 13) firstNameLabel.TabIndex = 17 firstNameLabel.Text = "First Name:" ' 'titleLabel ' titleLabel.AutoSize = True titleLabel.Location = New System.Drawing.Point(10, 52) titleLabel.Name = "titleLabel" titleLabel.Size = New System.Drawing.Size(30, 13) titleLabel.TabIndex = 4 titleLabel.Text = "Title:" ' 'customersBindingSource ' Me.customersBindingSource.DataMember = "customers" ' 'customersBindingSource1 ' Me.customersBindingSource1.DataMember = "customers" ' 'customersBindingSource2 ' Me.customersBindingSource2.DataMember = "customers" ' 'txtLastName ' Me.txtLastName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.customersBindingSource, "LastName", True)) Me.txtLastName.Location = New System.Drawing.Point(78, 84) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size(100, 20) Me.txtLastName.TabIndex = 19 ' 'groupBox2 ' Me.groupBox2.Controls.Add(lastNameLabel) Me.groupBox2.Controls.Add(Me.txtLastName) Me.groupBox2.Controls.Add(firstNameLabel) Me.groupBox2.Controls.Add(Me.txtFirstName) Me.groupBox2.Controls.Add(Me.tpBookDate) Me.groupBox2.Controls.Add(Me.cboCustomer) Me.groupBox2.Location = New System.Drawing.Point(334, 12) Me.groupBox2.Name = "groupBox2" Me.groupBox2.Size = New System.Drawing.Size(303, 159) Me.groupBox2.TabIndex = 3 Me.groupBox2.TabStop = False ' 'txtFirstName ' Me.txtFirstName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.customersBindingSource, "FirstName", True)) Me.txtFirstName.Location = New System.Drawing.Point(78, 46) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size(100, 20) Me.txtFirstName.TabIndex = 18 ' 'tpBookDate ' Me.tpBookDate.Location = New System.Drawing.Point(6, 119) Me.tpBookDate.Name = "tpBookDate" Me.tpBookDate.Size = New System.Drawing.Size(187, 20) Me.tpBookDate.TabIndex = 17 ' 'cboCustomer ' Me.cboCustomer.FormattingEnabled = True Me.cboCustomer.Location = New System.Drawing.Point(6, 19) Me.cboCustomer.Name = "cboCustomer" Me.cboCustomer.Size = New System.Drawing.Size(198, 21) Me.cboCustomer.TabIndex = 3 ' 'cboProduct ' Me.cboProduct.FormattingEnabled = True Me.cboProduct.Location = New System.Drawing.Point(6, 19) Me.cboProduct.Name = "cboProduct" Me.cboProduct.Size = New System.Drawing.Size(198, 21) Me.cboProduct.TabIndex = 2 ' 'productBindingSource ' productsBS.DataMember = "Product" ' 'groupBox1 ' Me.groupBox1.Controls.Add(titleLabel) Me.groupBox1.Controls.Add(Me.txtTitle) Me.groupBox1.Controls.Add(Me.cmdCheckout) Me.groupBox1.Controls.Add(Me.cboProduct) Me.groupBox1.Location = New System.Drawing.Point(12, 12) Me.groupBox1.Name = "groupBox1" Me.groupBox1.Size = New System.Drawing.Size(316, 159) Me.groupBox1.TabIndex = 2 Me.groupBox1.TabStop = False ' 'txtTitle ' Me.txtTitle.DataBindings.Add(New System.Windows.Forms.Binding("Text", productsBS, "Title", True)) Me.txtTitle.Location = New System.Drawing.Point(46, 49) Me.txtTitle.Name = "txtTitle" Me.txtTitle.Size = New System.Drawing.Size(100, 20) Me.txtTitle.TabIndex = 5 ' 'cmdCheckout ' Me.cmdCheckout.Location = New System.Drawing.Point(6, 120) Me.cmdCheckout.Name = "cmdCheckout" Me.cmdCheckout.Size = New System.Drawing.Size(186, 23) Me.cmdCheckout.TabIndex = 4 Me.cmdCheckout.Text = "Check-Out" Me.cmdCheckout.UseVisualStyleBackColor = True ' 'frmMakeBooking ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(646, 230) Me.Controls.Add(Me.groupBox2) Me.Controls.Add(Me.groupBox1) Me.Name = "frmMakeBooking" Me.Text = "frmMakeBooking" CType(Me.customersBindingSource, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.customersBindingSource1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.videostoreDataSetBindingSource, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.customersBindingSource2, System.ComponentModel.ISupportInitialize).EndInit() Me.groupBox2.ResumeLayout(False) Me.groupBox2.PerformLayout() CType(Me.movieBindingSource, System.ComponentModel.ISupportInitialize).EndInit() Me.groupBox1.ResumeLayout(False) Me.groupBox1.PerformLayout() Me.ResumeLayout(False) End Sub Private WithEvents customersBindingSource As System.Windows.Forms.BindingSource Private WithEvents customersBindingSource1 As System.Windows.Forms.BindingSource Private WithEvents videostoreDataSetBindingSource As System.Windows.Forms.BindingSource Private WithEvents customersBindingSource2 As System.Windows.Forms.BindingSource Private WithEvents txtLastName As System.Windows.Forms.TextBox Private WithEvents groupBox2 As System.Windows.Forms.GroupBox Private WithEvents txtFirstName As System.Windows.Forms.TextBox Private WithEvents tpBookDate As System.Windows.Forms.DateTimePicker Private WithEvents cboCustomer As System.Windows.Forms.ComboBox Private WithEvents cboProduct As System.Windows.Forms.ComboBox Private WithEvents movieBindingSource As System.Windows.Forms.BindingSource Private WithEvents groupBox1 As System.Windows.Forms.GroupBox Private WithEvents txtTitle As System.Windows.Forms.TextBox Private WithEvents cmdCheckout As System.Windows.Forms.Button End Class
Also, Warning: The variable 'productsBS' is either undeclared or was never assigned. frmMakeBooking.Designer.vb Lines 150 & 166
frmMakeBooking code
vb.net Code:
Public Class frmMakeBooking Private alibraryDS As New LibraryDataSet() Private aBookedTA As LibraryDataSetTableAdapters.BookedTableAdapter Private customersBS As New BindingSource() Private productsBS As New BindingSource() Private BookedBS As New BindingSource() Private query As New QueryDataContext() Private Sub cmdCheckout_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCheckout.Click If cmdCheckout.Text = "Check-Out Product" Then BookedBS.EndEdit() BookedBS.AddNew() cboProduct.Focus() cmdCheckout.Text = "Save" Else Try 'Save Button clicked BookedBS.EndEdit() aBookedTA.Update(alibraryDS.Booked) cmdCheckout.Text = "Check-Out Product" MessageBox.Show("Record Saved", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception 'Catch deplicate record and constraint violations MessageBox.Show(ex.Message) End Try End If End Sub Private Sub frmMakeBooking_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Dim Customers = query.ExecuteCommand("Select CustomerID FROM(Customers) WHERE (CustomerID > '0')") aBookedTA = New LibraryDataSetTableAdapters.BookedTableAdapter() MessageBox.Show("Boo") ' Try ' ' Set up the dataset ' Dim Customers = From Mem In query.Customers Where Mem.CustomerID <> "0" Select Mem ' Dim Products = From Mem In query.Products Where Mem.ProductID <> "0" Select Mem ' 'Set up binding source ' BookedBS.DataSource = alibraryDS ' BookedBS.DataMember = "Booked" ' customersBS.DataSource = Customers ' productsBS.DataSource = Products ' cboProduct.DataBindings.Clear() ' cboProduct.DataBindings.Add("text", BookedBS, "ProductID") ' cboProduct.DataSource = "Products" ' cboProduct.DisplayMember = "ProductID" ' cboCustomer.DataBindings.Add("text", BookedBS, "CustomerID") ' cboCustomer.DataSource = "Customers" ' cboCustomer.DisplayMember = "CustomerID" ' cboCustomer.DataBindings.Clear() ' tpBookDate.DataBindings.Clear() ' tpBookDate.DataBindings.Add("text", BookedBS, "RentDate") ' txtFirstName.DataBindings.Add("text", customersBS, "FirstName") ' txtLastName.DataBindings.Add("text", customersBS, "LastName") ' txtTitle.DataBindings.Add("text", productsBS, "Title") ' Catch ex As Exception ' MessageBox.Show(ex.Message) ' End Try End Sub End Class
Thanks,
Nightwalker






