Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27517

VS 2010 [RESOLVED] Cannot bind to the property or column LastName on the DataSource

$
0
0
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

vb.net Code:
  1. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
  2. Partial Class frmMakeBooking
  3.     Inherits System.Windows.Forms.Form
  4.  
  5.     'Form overrides dispose to clean up the component list.
  6.     <System.Diagnostics.DebuggerNonUserCode()> _
  7.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
  8.         Try
  9.             If disposing AndAlso components IsNot Nothing Then
  10.                 components.Dispose()
  11.             End If
  12.         Finally
  13.             MyBase.Dispose(disposing)
  14.         End Try
  15.     End Sub
  16.  
  17.     'Required by the Windows Form Designer
  18.     Private components As System.ComponentModel.IContainer
  19.  
  20.     'NOTE: The following procedure is required by the Windows Form Designer
  21.     'It can be modified using the Windows Form Designer.  
  22.     'Do not modify it using the code editor.
  23.     <System.Diagnostics.DebuggerStepThrough()> _
  24.     Private Sub InitializeComponent()
  25.         Me.components = New System.ComponentModel.Container
  26.         Dim lastNameLabel As System.Windows.Forms.Label
  27.         Dim firstNameLabel As System.Windows.Forms.Label
  28.         Dim titleLabel As System.Windows.Forms.Label
  29.         Me.customersBindingSource = New System.Windows.Forms.BindingSource(Me.components)
  30.         Me.customersBindingSource1 = New System.Windows.Forms.BindingSource(Me.components)
  31.         Me.videostoreDataSetBindingSource = New System.Windows.Forms.BindingSource(Me.components)
  32.         Me.customersBindingSource2 = New System.Windows.Forms.BindingSource(Me.components)
  33.         Me.txtLastName = New System.Windows.Forms.TextBox
  34.         Me.groupBox2 = New System.Windows.Forms.GroupBox
  35.         Me.txtFirstName = New System.Windows.Forms.TextBox
  36.         Me.tpBookDate = New System.Windows.Forms.DateTimePicker
  37.         Me.cboCustomer = New System.Windows.Forms.ComboBox
  38.         Me.cboProduct = New System.Windows.Forms.ComboBox
  39.         Me.movieBindingSource = New System.Windows.Forms.BindingSource(Me.components)
  40.         Me.groupBox1 = New System.Windows.Forms.GroupBox
  41.         Me.txtTitle = New System.Windows.Forms.TextBox
  42.         Me.cmdCheckout = New System.Windows.Forms.Button
  43.         lastNameLabel = New System.Windows.Forms.Label
  44.         firstNameLabel = New System.Windows.Forms.Label
  45.         titleLabel = New System.Windows.Forms.Label
  46.         CType(Me.customersBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
  47.         CType(Me.customersBindingSource1, System.ComponentModel.ISupportInitialize).BeginInit()
  48.         CType(Me.videostoreDataSetBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
  49.         CType(Me.customersBindingSource2, System.ComponentModel.ISupportInitialize).BeginInit()
  50.         Me.groupBox2.SuspendLayout()
  51.         CType(Me.movieBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
  52.         Me.groupBox1.SuspendLayout()
  53.         Me.SuspendLayout()
  54.         '
  55.         'lastNameLabel
  56.         '
  57.         lastNameLabel.AutoSize = True
  58.         lastNameLabel.Location = New System.Drawing.Point(11, 87)
  59.         lastNameLabel.Name = "lastNameLabel"
  60.         lastNameLabel.Size = New System.Drawing.Size(61, 13)
  61.         lastNameLabel.TabIndex = 18
  62.         lastNameLabel.Text = "Last Name:"
  63.         '
  64.         'firstNameLabel
  65.         '
  66.         firstNameLabel.AutoSize = True
  67.         firstNameLabel.Location = New System.Drawing.Point(12, 49)
  68.         firstNameLabel.Name = "firstNameLabel"
  69.         firstNameLabel.Size = New System.Drawing.Size(60, 13)
  70.         firstNameLabel.TabIndex = 17
  71.         firstNameLabel.Text = "First Name:"
  72.         '
  73.         'titleLabel
  74.         '
  75.         titleLabel.AutoSize = True
  76.         titleLabel.Location = New System.Drawing.Point(10, 52)
  77.         titleLabel.Name = "titleLabel"
  78.         titleLabel.Size = New System.Drawing.Size(30, 13)
  79.         titleLabel.TabIndex = 4
  80.         titleLabel.Text = "Title:"
  81.         '
  82.         'customersBindingSource
  83.         '
  84.         Me.customersBindingSource.DataMember = "customers"
  85.         '
  86.         'customersBindingSource1
  87.         '
  88.         Me.customersBindingSource1.DataMember = "customers"
  89.         '
  90.         'customersBindingSource2
  91.         '
  92.         Me.customersBindingSource2.DataMember = "customers"
  93.         '
  94.         'txtLastName
  95.         '
  96.         Me.txtLastName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.customersBindingSource, "LastName", True))
  97.         Me.txtLastName.Location = New System.Drawing.Point(78, 84)
  98.         Me.txtLastName.Name = "txtLastName"
  99.         Me.txtLastName.Size = New System.Drawing.Size(100, 20)
  100.         Me.txtLastName.TabIndex = 19
  101.         '
  102.         'groupBox2
  103.         '
  104.         Me.groupBox2.Controls.Add(lastNameLabel)
  105.         Me.groupBox2.Controls.Add(Me.txtLastName)
  106.         Me.groupBox2.Controls.Add(firstNameLabel)
  107.         Me.groupBox2.Controls.Add(Me.txtFirstName)
  108.         Me.groupBox2.Controls.Add(Me.tpBookDate)
  109.         Me.groupBox2.Controls.Add(Me.cboCustomer)
  110.         Me.groupBox2.Location = New System.Drawing.Point(334, 12)
  111.         Me.groupBox2.Name = "groupBox2"
  112.         Me.groupBox2.Size = New System.Drawing.Size(303, 159)
  113.         Me.groupBox2.TabIndex = 3
  114.         Me.groupBox2.TabStop = False
  115.         '
  116.         'txtFirstName
  117.         '
  118.         Me.txtFirstName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.customersBindingSource, "FirstName", True))
  119.         Me.txtFirstName.Location = New System.Drawing.Point(78, 46)
  120.         Me.txtFirstName.Name = "txtFirstName"
  121.         Me.txtFirstName.Size = New System.Drawing.Size(100, 20)
  122.         Me.txtFirstName.TabIndex = 18
  123.         '
  124.         'tpBookDate
  125.         '
  126.         Me.tpBookDate.Location = New System.Drawing.Point(6, 119)
  127.         Me.tpBookDate.Name = "tpBookDate"
  128.         Me.tpBookDate.Size = New System.Drawing.Size(187, 20)
  129.         Me.tpBookDate.TabIndex = 17
  130.         '
  131.         'cboCustomer
  132.         '
  133.         Me.cboCustomer.FormattingEnabled = True
  134.         Me.cboCustomer.Location = New System.Drawing.Point(6, 19)
  135.         Me.cboCustomer.Name = "cboCustomer"
  136.         Me.cboCustomer.Size = New System.Drawing.Size(198, 21)
  137.         Me.cboCustomer.TabIndex = 3
  138.         '
  139.         'cboProduct
  140.         '
  141.         Me.cboProduct.FormattingEnabled = True
  142.         Me.cboProduct.Location = New System.Drawing.Point(6, 19)
  143.         Me.cboProduct.Name = "cboProduct"
  144.         Me.cboProduct.Size = New System.Drawing.Size(198, 21)
  145.         Me.cboProduct.TabIndex = 2
  146.         '
  147.         'productBindingSource
  148.         '
  149.         productsBS.DataMember = "Product"
  150.         '
  151.         'groupBox1
  152.         '
  153.         Me.groupBox1.Controls.Add(titleLabel)
  154.         Me.groupBox1.Controls.Add(Me.txtTitle)
  155.         Me.groupBox1.Controls.Add(Me.cmdCheckout)
  156.         Me.groupBox1.Controls.Add(Me.cboProduct)
  157.         Me.groupBox1.Location = New System.Drawing.Point(12, 12)
  158.         Me.groupBox1.Name = "groupBox1"
  159.         Me.groupBox1.Size = New System.Drawing.Size(316, 159)
  160.         Me.groupBox1.TabIndex = 2
  161.         Me.groupBox1.TabStop = False
  162.         '
  163.         'txtTitle
  164.         '
  165.         Me.txtTitle.DataBindings.Add(New System.Windows.Forms.Binding("Text", productsBS, "Title", True))
  166.         Me.txtTitle.Location = New System.Drawing.Point(46, 49)
  167.         Me.txtTitle.Name = "txtTitle"
  168.         Me.txtTitle.Size = New System.Drawing.Size(100, 20)
  169.         Me.txtTitle.TabIndex = 5
  170.         '
  171.         'cmdCheckout
  172.         '
  173.         Me.cmdCheckout.Location = New System.Drawing.Point(6, 120)
  174.         Me.cmdCheckout.Name = "cmdCheckout"
  175.         Me.cmdCheckout.Size = New System.Drawing.Size(186, 23)
  176.         Me.cmdCheckout.TabIndex = 4
  177.         Me.cmdCheckout.Text = "Check-Out"
  178.         Me.cmdCheckout.UseVisualStyleBackColor = True
  179.         '
  180.         'frmMakeBooking
  181.         '
  182.         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
  183.         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
  184.         Me.ClientSize = New System.Drawing.Size(646, 230)
  185.         Me.Controls.Add(Me.groupBox2)
  186.         Me.Controls.Add(Me.groupBox1)
  187.         Me.Name = "frmMakeBooking"
  188.         Me.Text = "frmMakeBooking"
  189.         CType(Me.customersBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
  190.         CType(Me.customersBindingSource1, System.ComponentModel.ISupportInitialize).EndInit()
  191.         CType(Me.videostoreDataSetBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
  192.         CType(Me.customersBindingSource2, System.ComponentModel.ISupportInitialize).EndInit()
  193.         Me.groupBox2.ResumeLayout(False)
  194.         Me.groupBox2.PerformLayout()
  195.         CType(Me.movieBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
  196.         Me.groupBox1.ResumeLayout(False)
  197.         Me.groupBox1.PerformLayout()
  198.         Me.ResumeLayout(False)
  199.  
  200.     End Sub
  201.     Private WithEvents customersBindingSource As System.Windows.Forms.BindingSource
  202.     Private WithEvents customersBindingSource1 As System.Windows.Forms.BindingSource
  203.     Private WithEvents videostoreDataSetBindingSource As System.Windows.Forms.BindingSource
  204.     Private WithEvents customersBindingSource2 As System.Windows.Forms.BindingSource
  205.     Private WithEvents txtLastName As System.Windows.Forms.TextBox
  206.     Private WithEvents groupBox2 As System.Windows.Forms.GroupBox
  207.     Private WithEvents txtFirstName As System.Windows.Forms.TextBox
  208.     Private WithEvents tpBookDate As System.Windows.Forms.DateTimePicker
  209.     Private WithEvents cboCustomer As System.Windows.Forms.ComboBox
  210.     Private WithEvents cboProduct As System.Windows.Forms.ComboBox
  211.     Private WithEvents movieBindingSource As System.Windows.Forms.BindingSource
  212.     Private WithEvents groupBox1 As System.Windows.Forms.GroupBox
  213.     Private WithEvents txtTitle As System.Windows.Forms.TextBox
  214.     Private WithEvents cmdCheckout As System.Windows.Forms.Button
  215. 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:
  1. Public Class frmMakeBooking
  2.  
  3.     Private alibraryDS As New LibraryDataSet()
  4.     Private aBookedTA As LibraryDataSetTableAdapters.BookedTableAdapter
  5.     Private customersBS As New BindingSource()
  6.     Private productsBS As New BindingSource()
  7.     Private BookedBS As New BindingSource()
  8.     Private query As New QueryDataContext()
  9.  
  10.     Private Sub cmdCheckout_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCheckout.Click
  11.         If cmdCheckout.Text = "Check-Out Product" Then
  12.             BookedBS.EndEdit()
  13.             BookedBS.AddNew()
  14.             cboProduct.Focus()
  15.             cmdCheckout.Text = "Save"
  16.         Else
  17.             Try
  18.                 'Save Button clicked
  19.                 BookedBS.EndEdit()
  20.                 aBookedTA.Update(alibraryDS.Booked)
  21.  
  22.                 cmdCheckout.Text = "Check-Out Product"
  23.                 MessageBox.Show("Record Saved", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information)
  24.             Catch ex As Exception
  25.                 'Catch deplicate record and constraint violations
  26.                 MessageBox.Show(ex.Message)
  27.             End Try
  28.         End If
  29.     End Sub
  30.  
  31.  
  32.  
  33.     Private Sub frmMakeBooking_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  34.         'Dim Customers = query.ExecuteCommand("Select CustomerID FROM(Customers) WHERE (CustomerID > '0')")
  35.         aBookedTA = New LibraryDataSetTableAdapters.BookedTableAdapter()
  36.         MessageBox.Show("Boo")
  37.     '    Try
  38.     '        ' Set up the dataset
  39.     '        Dim Customers = From Mem In query.Customers Where Mem.CustomerID <> "0" Select Mem
  40.     '        Dim Products = From Mem In query.Products Where Mem.ProductID <> "0" Select Mem
  41.  
  42.     '        'Set up binding source
  43.     '        BookedBS.DataSource = alibraryDS
  44.     '        BookedBS.DataMember = "Booked"
  45.     '        customersBS.DataSource = Customers
  46.     '        productsBS.DataSource = Products
  47.     '        cboProduct.DataBindings.Clear()
  48.     '        cboProduct.DataBindings.Add("text", BookedBS, "ProductID")
  49.     '        cboProduct.DataSource = "Products"
  50.     '        cboProduct.DisplayMember = "ProductID"
  51.     '        cboCustomer.DataBindings.Add("text", BookedBS, "CustomerID")
  52.     '        cboCustomer.DataSource = "Customers"
  53.     '        cboCustomer.DisplayMember = "CustomerID"
  54.     '        cboCustomer.DataBindings.Clear()
  55.     '        tpBookDate.DataBindings.Clear()
  56.     '        tpBookDate.DataBindings.Add("text", BookedBS, "RentDate")
  57.     '        txtFirstName.DataBindings.Add("text", customersBS, "FirstName")
  58.     '        txtLastName.DataBindings.Add("text", customersBS, "LastName")
  59.     '        txtTitle.DataBindings.Add("text", productsBS, "Title")
  60.     '    Catch ex As Exception
  61.     '        MessageBox.Show(ex.Message)
  62.     '    End Try
  63.     End Sub
  64. End Class

Thanks,


Nightwalker

Viewing all articles
Browse latest Browse all 27517

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>