?
Solved

Binding code does not work correctly

Posted on 2005-02-26
5
Medium Priority
?
213 Views
Last Modified: 2008-02-01
When I run my program all my values appear in the text box.  Can someone give insight why the values are not showing up in the lblprompt.  See below the code I have written, thanks in advance.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pintRecords As Integer
        Dim pbndTemp As Binding, pdtParts As DataTable
        pdtParts = DsParts1.tblParts
        pbndTemp = New Binding("Text", DsParts1, _
            "tblParts.fldPartNumber")
        pbndTemp = New Binding("Text", pdtParts, _
            "fldParts")

        ' Comment
        pintRecords = odbdaParts.Fill(DsParts1)

        ' Setup binding for each form control instance.
        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldPartNumber")
        txtPartNumber.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldDescription")
        txtDescription.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldQuantityOnHand")
        txtQuantityOnHand.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldCost")
        txtCost.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldSalesPrice")
        txtSalesPrice.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldGrossProfitPerItem")
        txtGrossProfit.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldTotalInventoryAtCost")
        txtTotalInvCost.DataBindings.Add(pbndTemp)

        ' Set the initial edit state so that the menu items are set up properly, and the
        ' text boxes are disabled.
        Call EditState(cblnNotEditing)
    End Sub
0
Comment
Question by:kwnelson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Lacutah
ID: 13412084
Am I missunderstanding - there is no "lblprompt" in your code?
0
 

Author Comment

by:kwnelson
ID: 13412388
I aplogize about the confusion.  I have created the form with text boxes and lbl.  Where would I add code to bind the text box with lblprompt; so the value appears in the lblprompt
0
 

Author Comment

by:kwnelson
ID: 13412476
Here is the code.  I am still only getting values in the text box (left side of form), which should be in the lblprompt (right side of form).  Any help or suggestions will be appreciated, thanks in advance.

Option Strict On
Option Explicit On

Imports System.Convert
Imports System.Data
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 MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents mmuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEdit As System.Windows.Forms.MenuItem
    Friend WithEvents mmuNavigate As System.Windows.Forms.MenuItem
    Friend WithEvents mmuFileExit As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEditAdd As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEditEdit As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEditCancel As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEditUpdate As System.Windows.Forms.MenuItem
    Friend WithEvents mmuEditDelete As System.Windows.Forms.MenuItem
    Friend WithEvents mmuNavigateFirst As System.Windows.Forms.MenuItem
    Friend WithEvents mmuNavigatePrevious As System.Windows.Forms.MenuItem
    Friend WithEvents mmuNavigateNext As System.Windows.Forms.MenuItem
    Friend WithEvents mmuNavigateLast As System.Windows.Forms.MenuItem
    Friend WithEvents txtPartNumber As System.Windows.Forms.TextBox
    Friend WithEvents txtDescription As System.Windows.Forms.TextBox
    Friend WithEvents txtQuantityOnHand As System.Windows.Forms.TextBox
    Friend WithEvents txtCost As System.Windows.Forms.TextBox
    Friend WithEvents txtSalesPrice As System.Windows.Forms.TextBox
    Friend WithEvents lblPromptPartnumber As System.Windows.Forms.Label
    Friend WithEvents lblPromptDescription As System.Windows.Forms.Label
    Friend WithEvents lblPromptQuantityOnHand As System.Windows.Forms.Label
    Friend WithEvents lblPromptCost As System.Windows.Forms.Label
    Friend WithEvents lblPromptSalesPrice As System.Windows.Forms.Label
    Friend WithEvents lblPromptGrossProfitPerItem As System.Windows.Forms.Label
    Friend WithEvents lblTotalInventoryAtCost As System.Windows.Forms.Label
    Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents DsParts1 As KelvinNelson_Unit02.sln.dsParts
    Friend WithEvents odbconParts As System.Data.OleDb.OleDbConnection
    Friend WithEvents odbdaParts As System.Data.OleDb.OleDbDataAdapter
    Friend WithEvents txtTotalInvCost As System.Windows.Forms.TextBox
    Friend WithEvents txtGrossProfit As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.mmuFile = New System.Windows.Forms.MenuItem
        Me.mmuFileExit = New System.Windows.Forms.MenuItem
        Me.mmuEdit = New System.Windows.Forms.MenuItem
        Me.mmuEditAdd = New System.Windows.Forms.MenuItem
        Me.mmuEditEdit = New System.Windows.Forms.MenuItem
        Me.mmuEditCancel = New System.Windows.Forms.MenuItem
        Me.mmuEditUpdate = New System.Windows.Forms.MenuItem
        Me.mmuEditDelete = New System.Windows.Forms.MenuItem
        Me.mmuNavigate = New System.Windows.Forms.MenuItem
        Me.mmuNavigateFirst = New System.Windows.Forms.MenuItem
        Me.mmuNavigatePrevious = New System.Windows.Forms.MenuItem
        Me.mmuNavigateNext = New System.Windows.Forms.MenuItem
        Me.mmuNavigateLast = New System.Windows.Forms.MenuItem
        Me.txtPartNumber = New System.Windows.Forms.TextBox
        Me.txtDescription = New System.Windows.Forms.TextBox
        Me.txtQuantityOnHand = New System.Windows.Forms.TextBox
        Me.txtCost = New System.Windows.Forms.TextBox
        Me.txtSalesPrice = New System.Windows.Forms.TextBox
        Me.txtGrossProfit = New System.Windows.Forms.TextBox
        Me.txtTotalInvCost = New System.Windows.Forms.TextBox
        Me.lblPromptPartnumber = New System.Windows.Forms.Label
        Me.lblPromptDescription = New System.Windows.Forms.Label
        Me.lblPromptQuantityOnHand = New System.Windows.Forms.Label
        Me.lblPromptCost = New System.Windows.Forms.Label
        Me.lblPromptSalesPrice = New System.Windows.Forms.Label
        Me.lblPromptGrossProfitPerItem = New System.Windows.Forms.Label
        Me.lblTotalInventoryAtCost = New System.Windows.Forms.Label
        Me.odbconParts = New System.Data.OleDb.OleDbConnection
        Me.odbdaParts = New System.Data.OleDb.OleDbDataAdapter
        Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
        Me.DsParts1 = New KelvinNelson_Unit02.sln.dsParts
        CType(Me.DsParts1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuFile, Me.mmuEdit, Me.mmuNavigate})
        '
        'mmuFile
        '
        Me.mmuFile.Index = 0
        Me.mmuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuFileExit})
        Me.mmuFile.Text = "&File"
        '
        'mmuFileExit
        '
        Me.mmuFileExit.Index = 0
        Me.mmuFileExit.Shortcut = System.Windows.Forms.Shortcut.CtrlX
        Me.mmuFileExit.Text = "E&xit"
        '
        'mmuEdit
        '
        Me.mmuEdit.Index = 1
        Me.mmuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuEditAdd, Me.mmuEditEdit, Me.mmuEditCancel, Me.mmuEditUpdate, Me.mmuEditDelete})
        Me.mmuEdit.Text = "&Edit"
        '
        'mmuEditAdd
        '
        Me.mmuEditAdd.Index = 0
        Me.mmuEditAdd.Shortcut = System.Windows.Forms.Shortcut.CtrlA
        Me.mmuEditAdd.Text = "&Add"
        '
        'mmuEditEdit
        '
        Me.mmuEditEdit.Index = 1
        Me.mmuEditEdit.Shortcut = System.Windows.Forms.Shortcut.CtrlD
        Me.mmuEditEdit.Text = "E&dit"
        '
        'mmuEditCancel
        '
        Me.mmuEditCancel.Index = 2
        Me.mmuEditCancel.Shortcut = System.Windows.Forms.Shortcut.CtrlC
        Me.mmuEditCancel.Text = "&Cancel"
        '
        'mmuEditUpdate
        '
        Me.mmuEditUpdate.Index = 3
        Me.mmuEditUpdate.Shortcut = System.Windows.Forms.Shortcut.CtrlU
        Me.mmuEditUpdate.Text = "&Update"
        '
        'mmuEditDelete
        '
        Me.mmuEditDelete.Index = 4
        Me.mmuEditDelete.Text = "&Delete"
        '
        'mmuNavigate
        '
        Me.mmuNavigate.Index = 2
        Me.mmuNavigate.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuNavigateFirst, Me.mmuNavigatePrevious, Me.mmuNavigateNext, Me.mmuNavigateLast})
        Me.mmuNavigate.RadioCheck = CType(configurationAppSettings.GetValue("mmuNavigate.RadioCheck", GetType(System.Boolean)), Boolean)
        Me.mmuNavigate.ShowShortcut = CType(configurationAppSettings.GetValue("mmuNavigate.ShowShortcut", GetType(System.Boolean)), Boolean)
        Me.mmuNavigate.Text = "&Navigate"
        '
        'mmuNavigateFirst
        '
        Me.mmuNavigateFirst.Index = 0
        Me.mmuNavigateFirst.RadioCheck = True
        Me.mmuNavigateFirst.Shortcut = System.Windows.Forms.Shortcut.CtrlF
        Me.mmuNavigateFirst.Text = "&First"
        '
        'mmuNavigatePrevious
        '
        Me.mmuNavigatePrevious.Index = 1
        Me.mmuNavigatePrevious.Shortcut = System.Windows.Forms.Shortcut.CtrlP
        Me.mmuNavigatePrevious.Text = "&Previous"
        '
        'mmuNavigateNext
        '
        Me.mmuNavigateNext.Index = 2
        Me.mmuNavigateNext.Shortcut = System.Windows.Forms.Shortcut.CtrlT
        Me.mmuNavigateNext.Text = "Nex&t"
        '
        'mmuNavigateLast
        '
        Me.mmuNavigateLast.Index = 3
        Me.mmuNavigateLast.Shortcut = System.Windows.Forms.Shortcut.CtrlL
        Me.mmuNavigateLast.Text = "&Last"
        '
        'txtPartNumber
        '
        Me.txtPartNumber.BackColor = System.Drawing.Color.White
        Me.txtPartNumber.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtPartNumber.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtPartNumber.ImeMode = System.Windows.Forms.ImeMode.NoControl
        Me.txtPartNumber.Location = New System.Drawing.Point(80, 48)
        Me.txtPartNumber.Name = "txtPartNumber"
        Me.txtPartNumber.ReadOnly = True
        Me.txtPartNumber.Size = New System.Drawing.Size(104, 20)
        Me.txtPartNumber.TabIndex = 0
        Me.txtPartNumber.TabStop = False
        Me.txtPartNumber.Text = "Part Number:"
        Me.txtPartNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtDescription
        '
        Me.txtDescription.AcceptsTab = True
        Me.txtDescription.BackColor = System.Drawing.Color.White
        Me.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtDescription.Location = New System.Drawing.Point(96, 80)
        Me.txtDescription.Name = "txtDescription"
        Me.txtDescription.ReadOnly = True
        Me.txtDescription.Size = New System.Drawing.Size(88, 20)
        Me.txtDescription.TabIndex = 2
        Me.txtDescription.TabStop = False
        Me.txtDescription.Text = "Description:"
        Me.txtDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtQuantityOnHand
        '
        Me.txtQuantityOnHand.AcceptsTab = True
        Me.txtQuantityOnHand.BackColor = System.Drawing.Color.White
        Me.txtQuantityOnHand.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtQuantityOnHand.Location = New System.Drawing.Point(56, 112)
        Me.txtQuantityOnHand.Name = "txtQuantityOnHand"
        Me.txtQuantityOnHand.ReadOnly = True
        Me.txtQuantityOnHand.Size = New System.Drawing.Size(128, 20)
        Me.txtQuantityOnHand.TabIndex = 4
        Me.txtQuantityOnHand.TabStop = False
        Me.txtQuantityOnHand.Text = "Quantity On Hand:"
        Me.txtQuantityOnHand.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtCost
        '
        Me.txtCost.AcceptsTab = True
        Me.txtCost.BackColor = System.Drawing.Color.White
        Me.txtCost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtCost.Location = New System.Drawing.Point(128, 144)
        Me.txtCost.Name = "txtCost"
        Me.txtCost.ReadOnly = True
        Me.txtCost.Size = New System.Drawing.Size(56, 20)
        Me.txtCost.TabIndex = 6
        Me.txtCost.TabStop = False
        Me.txtCost.Text = "Cost:"
        Me.txtCost.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtSalesPrice
        '
        Me.txtSalesPrice.AcceptsTab = True
        Me.txtSalesPrice.BackColor = System.Drawing.Color.White
        Me.txtSalesPrice.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtSalesPrice.Location = New System.Drawing.Point(104, 176)
        Me.txtSalesPrice.Name = "txtSalesPrice"
        Me.txtSalesPrice.ReadOnly = True
        Me.txtSalesPrice.Size = New System.Drawing.Size(80, 20)
        Me.txtSalesPrice.TabIndex = 8
        Me.txtSalesPrice.TabStop = False
        Me.txtSalesPrice.Text = "Sales Price:"
        Me.txtSalesPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtGrossProfit
        '
        Me.txtGrossProfit.AcceptsTab = True
        Me.txtGrossProfit.BackColor = System.Drawing.Color.White
        Me.txtGrossProfit.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtGrossProfit.Location = New System.Drawing.Point(48, 208)
        Me.txtGrossProfit.Name = "txtGrossProfit"
        Me.txtGrossProfit.ReadOnly = True
        Me.txtGrossProfit.Size = New System.Drawing.Size(136, 20)
        Me.txtGrossProfit.TabIndex = 10
        Me.txtGrossProfit.TabStop = False
        Me.txtGrossProfit.Text = "Gross Profit Per Item:"
        Me.txtGrossProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'txtTotalInvCost
        '
        Me.txtTotalInvCost.AcceptsTab = True
        Me.txtTotalInvCost.BackColor = System.Drawing.Color.White
        Me.txtTotalInvCost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtTotalInvCost.Location = New System.Drawing.Point(24, 240)
        Me.txtTotalInvCost.Name = "txtTotalInvCost"
        Me.txtTotalInvCost.ReadOnly = True
        Me.txtTotalInvCost.Size = New System.Drawing.Size(160, 20)
        Me.txtTotalInvCost.TabIndex = 12
        Me.txtTotalInvCost.TabStop = False
        Me.txtTotalInvCost.Text = "Total Inventory At Cost:"
        Me.txtTotalInvCost.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'lblPromptPartnumber
        '
        Me.lblPromptPartnumber.BackColor = System.Drawing.Color.White
        Me.lblPromptPartnumber.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptPartnumber.ForeColor = System.Drawing.SystemColors.ControlText
        Me.lblPromptPartnumber.Location = New System.Drawing.Point(208, 48)
        Me.lblPromptPartnumber.Name = "lblPromptPartnumber"
        Me.lblPromptPartnumber.Size = New System.Drawing.Size(136, 20)
        Me.lblPromptPartnumber.TabIndex = 1
        '
        'lblPromptDescription
        '
        Me.lblPromptDescription.BackColor = System.Drawing.Color.White
        Me.lblPromptDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptDescription.Location = New System.Drawing.Point(208, 80)
        Me.lblPromptDescription.Name = "lblPromptDescription"
        Me.lblPromptDescription.Size = New System.Drawing.Size(136, 20)
        Me.lblPromptDescription.TabIndex = 3
        '
        'lblPromptQuantityOnHand
        '
        Me.lblPromptQuantityOnHand.BackColor = System.Drawing.Color.White
        Me.lblPromptQuantityOnHand.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptQuantityOnHand.Location = New System.Drawing.Point(208, 112)
        Me.lblPromptQuantityOnHand.Name = "lblPromptQuantityOnHand"
        Me.lblPromptQuantityOnHand.Size = New System.Drawing.Size(64, 20)
        Me.lblPromptQuantityOnHand.TabIndex = 5
        Me.lblPromptQuantityOnHand.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblPromptCost
        '
        Me.lblPromptCost.BackColor = System.Drawing.Color.White
        Me.lblPromptCost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptCost.Location = New System.Drawing.Point(208, 144)
        Me.lblPromptCost.Name = "lblPromptCost"
        Me.lblPromptCost.Size = New System.Drawing.Size(80, 20)
        Me.lblPromptCost.TabIndex = 7
        Me.lblPromptCost.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblPromptSalesPrice
        '
        Me.lblPromptSalesPrice.BackColor = System.Drawing.Color.White
        Me.lblPromptSalesPrice.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptSalesPrice.Location = New System.Drawing.Point(208, 176)
        Me.lblPromptSalesPrice.Name = "lblPromptSalesPrice"
        Me.lblPromptSalesPrice.Size = New System.Drawing.Size(80, 20)
        Me.lblPromptSalesPrice.TabIndex = 9
        Me.lblPromptSalesPrice.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblPromptGrossProfitPerItem
        '
        Me.lblPromptGrossProfitPerItem.BackColor = System.Drawing.Color.White
        Me.lblPromptGrossProfitPerItem.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPromptGrossProfitPerItem.Location = New System.Drawing.Point(208, 208)
        Me.lblPromptGrossProfitPerItem.Name = "lblPromptGrossProfitPerItem"
        Me.lblPromptGrossProfitPerItem.Size = New System.Drawing.Size(80, 20)
        Me.lblPromptGrossProfitPerItem.TabIndex = 11
        Me.lblPromptGrossProfitPerItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'lblTotalInventoryAtCost
        '
        Me.lblTotalInventoryAtCost.BackColor = System.Drawing.Color.White
        Me.lblTotalInventoryAtCost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblTotalInventoryAtCost.Location = New System.Drawing.Point(208, 240)
        Me.lblTotalInventoryAtCost.Name = "lblTotalInventoryAtCost"
        Me.lblTotalInventoryAtCost.Size = New System.Drawing.Size(80, 20)
        Me.lblTotalInventoryAtCost.TabIndex = 13
        Me.lblTotalInventoryAtCost.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'odbconParts
        '
        Me.odbconParts.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
        "ocking Mode=1;Data Source=""C:\Datafiles\Myfiles.mdb"";Mode=Share Deny None;Jet OL" & _
        "EDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;" & _
        "Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:C" & _
        "ompact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:C" & _
        "reate System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID" & _
        "=Admin;Jet OLEDB:Global Bulk Transactions=1"
        '
        'odbdaParts
        '
        Me.odbdaParts.DeleteCommand = Me.OleDbDeleteCommand1
        Me.odbdaParts.InsertCommand = Me.OleDbInsertCommand1
        Me.odbdaParts.SelectCommand = Me.OleDbSelectCommand1
        Me.odbdaParts.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "tblParts", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("fldCost", "fldCost"), New System.Data.Common.DataColumnMapping("fldDescription", "fldDescription"), New System.Data.Common.DataColumnMapping("fldPartNumber", "fldPartNumber"), New System.Data.Common.DataColumnMapping("fldQuantityOnHand", "fldQuantityOnHand"), New System.Data.Common.DataColumnMapping("fldSalesPrice", "fldSalesPrice")})})
        Me.odbdaParts.UpdateCommand = Me.OleDbUpdateCommand1
        '
        'OleDbDeleteCommand1
        '
        Me.OleDbDeleteCommand1.CommandText = "DELETE FROM tblParts WHERE (fldPartNumber = ?) AND (fldCost = ? OR ? IS NULL AND " & _
        "fldCost IS NULL) AND (fldDescription = ? OR ? IS NULL AND fldDescription IS NULL" & _
        ") AND (fldQuantityOnHand = ? OR ? IS NULL AND fldQuantityOnHand IS NULL) AND (fl" & _
        "dSalesPrice = ? OR ? IS NULL AND fldSalesPrice IS NULL)"
        Me.OleDbDeleteCommand1.Connection = Me.odbconParts
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPartNumber", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPartNumber", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCost", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCost", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCost1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCost", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldDescription", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldDescription", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldDescription1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldDescription", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldQuantityOnHand", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldQuantityOnHand", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldQuantityOnHand1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldQuantityOnHand", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldSalesPrice", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldSalesPrice", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldSalesPrice1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldSalesPrice", System.Data.DataRowVersion.Original, Nothing))
        '
        'OleDbInsertCommand1
        '
        Me.OleDbInsertCommand1.CommandText = "INSERT INTO tblParts(fldCost, fldDescription, fldPartNumber, fldQuantityOnHand, f" & _
        "ldSalesPrice) VALUES (?, ?, ?, ?, ?)"
        Me.OleDbInsertCommand1.Connection = Me.odbconParts
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCost", System.Data.OleDb.OleDbType.Single, 0, "fldCost"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldDescription", System.Data.OleDb.OleDbType.VarWChar, 50, "fldDescription"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPartNumber", System.Data.OleDb.OleDbType.Integer, 0, "fldPartNumber"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldQuantityOnHand", System.Data.OleDb.OleDbType.Single, 0, "fldQuantityOnHand"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldSalesPrice", System.Data.OleDb.OleDbType.Single, 0, "fldSalesPrice"))
        '
        'OleDbSelectCommand1
        '
        Me.OleDbSelectCommand1.CommandText = "SELECT fldCost, fldDescription, fldPartNumber, fldQuantityOnHand, fldSalesPrice F" & _
        "ROM tblParts"
        Me.OleDbSelectCommand1.Connection = Me.odbconParts
        '
        'OleDbUpdateCommand1
        '
        Me.OleDbUpdateCommand1.CommandText = "UPDATE tblParts SET fldCost = ?, fldDescription = ?, fldPartNumber = ?, fldQuanti" & _
        "tyOnHand = ?, fldSalesPrice = ? WHERE (fldPartNumber = ?) AND (fldCost = ? OR ? " & _
        "IS NULL AND fldCost IS NULL) AND (fldDescription = ? OR ? IS NULL AND fldDescrip" & _
        "tion IS NULL) AND (fldQuantityOnHand = ? OR ? IS NULL AND fldQuantityOnHand IS N" & _
        "ULL) AND (fldSalesPrice = ? OR ? IS NULL AND fldSalesPrice IS NULL)"
        Me.OleDbUpdateCommand1.Connection = Me.odbconParts
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCost", System.Data.OleDb.OleDbType.Single, 0, "fldCost"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldDescription", System.Data.OleDb.OleDbType.VarWChar, 50, "fldDescription"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPartNumber", System.Data.OleDb.OleDbType.Integer, 0, "fldPartNumber"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldQuantityOnHand", System.Data.OleDb.OleDbType.Single, 0, "fldQuantityOnHand"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldSalesPrice", System.Data.OleDb.OleDbType.Single, 0, "fldSalesPrice"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPartNumber", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPartNumber", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCost", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCost", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCost1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCost", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldDescription", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldDescription", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldDescription1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldDescription", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldQuantityOnHand", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldQuantityOnHand", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldQuantityOnHand1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldQuantityOnHand", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldSalesPrice", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldSalesPrice", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldSalesPrice1", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldSalesPrice", System.Data.DataRowVersion.Original, Nothing))
        '
        'DsParts1
        '
        Me.DsParts1.DataSetName = "dsParts"
        Me.DsParts1.Locale = New System.Globalization.CultureInfo("en-US")
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(416, 305)
        Me.Controls.Add(Me.lblTotalInventoryAtCost)
        Me.Controls.Add(Me.lblPromptGrossProfitPerItem)
        Me.Controls.Add(Me.lblPromptSalesPrice)
        Me.Controls.Add(Me.lblPromptCost)
        Me.Controls.Add(Me.lblPromptQuantityOnHand)
        Me.Controls.Add(Me.lblPromptDescription)
        Me.Controls.Add(Me.lblPromptPartnumber)
        Me.Controls.Add(Me.txtTotalInvCost)
        Me.Controls.Add(Me.txtGrossProfit)
        Me.Controls.Add(Me.txtSalesPrice)
        Me.Controls.Add(Me.txtCost)
        Me.Controls.Add(Me.txtQuantityOnHand)
        Me.Controls.Add(Me.txtDescription)
        Me.Controls.Add(Me.txtPartNumber)
        Me.Menu = Me.MainMenu1
        Me.Name = "Form1"
        Me.Text = "KelvinNelson_Unit02"
        CType(Me.DsParts1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    ' Declate two constants for the EditState procedure.
    ' The constants will determine if the current record(s) allow editing.
    Private Const cblnEditing As Boolean = True
    Private Const cblnNotEditing As Boolean = False

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPromptPartnumber.Click

    End Sub

    Private Sub lblPromptQuantityOnHand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPromptQuantityOnHand.Click

    End Sub

    Private Sub mmuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuFileExit.Click
        Me.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pintRecords As Integer
        Dim pbndTemp As Binding
        pintRecords = odbdaParts.Fill(DsParts1)

        ' Setup binding for each form control instance.
        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldPartNumber")
        txtPartNumber.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldDescription")
        txtDescription.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldCost")
        txtCost.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldSalesPrice")
        txtSalesPrice.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsParts1, _
            "tblparts.fldQuantityOnHand")
        txtQuantityOnHand.DataBindings.Add(pbndTemp)

        ' Set the initial edit state so that the menu items are set up properly, and the
        ' text boxes are disabled.
        Call EditState(cblnNotEditing)
    End Sub
    ' Add a new row to the DataSet.
    Private Sub mmuEditAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuEditAdd.Click
        ' Set the menu items to indicate that a record is being edited.
        Call EditState(cblnNotEditing)

        ' Add the new record to the BindingContext.
        Me.BindingContext(DsParts1, "tblparts").AddNew()
    End Sub
    ' Editing is not permitted while current record is being modified.
    Private Sub mmuEditEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuEditEdit.Click
        Call EditState(cblnNotEditing)
    End Sub
    ' Cancel editing on the current record.
    Private Sub mmuEditCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuEditCancel.Click
        Call EditState(cblnNotEditing)
        Me.BindingContext(DsParts1, "tblParts").CancelCurrentEdit()
    End Sub
    ' Update the current record.
    Private Sub mmuEditUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuEditUpdate.Click
        ' Temporary DataSets to store the inserted or modified row.
        Dim pdsInsertedRows, pdsModifiedRows As DataSet

        ' Set the menu items to indicate that a record is being edited.
        Call EditState(cblnNotEditing)

        ' End editing on the current record.
        Me.BindingContext(DsParts1, "tblparts").EndCurrentEdit()

        ' Copy the DataSets by getting the added or modified records from the
        ' original bound DataSet.
        pdsInsertedRows = DsParts1.GetChanges(DataRowState.Added)
        pdsModifiedRows = DsParts1.GetChanges(DataRowState.Modified)

        ' Check to see if there is an inserted row. If there is, update the
        ' DataSet.
        If Not pdsInsertedRows Is Nothing Then
            odbdaParts.Update(pdsInsertedRows)
        End If

        ' Check to see if there is a modified row. If there is, update the
        ' DataSet.
        If Not pdsModifiedRows Is Nothing Then
            odbdaParts.Update(pdsModifiedRows)
        End If

        ' Synchronize the database with the DataSet by accepting the changes.
        DsParts1.AcceptChanges()
    End Sub
    ' Delete the current row
    Private Sub mmuEditDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuEditDelete.Click
        ' Temporary DataSet to store the deleted row.
        Dim pdsDeletedRows As DataSet

        ' Remove the current record from the BindingContext.
        Me.BindingContext(DsParts1, "tblparts"). _
            RemoveAt(Me.BindingContext(DsParts1, "tblparts").Position)

        ' Create the temporary DataSet to store the deleted row.
        pdsDeletedRows = DsParts1.GetChanges(DataRowState.Deleted)

        ' Delete the row from the database.
        odbdaParts.Update(pdsDeletedRows)

        ' Synchronize the DataSet and the database.
        DsParts1.AcceptChanges()
    End Sub
    ' Locate the firest row in the BindingContext. we use the DataSet name and the path to
    ' the table to specify the BindingContext. Use the Position property to select the
    ' first record.
    Private Sub mmuNavigateFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuNavigateFirst.Click
        Me.BindingContext(DsParts1, "tblparts").Position = 0
    End Sub

    Private Sub mmuNavigatePrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuNavigatePrevious.Click
        Me.BindingContext(DsParts1, "tblparts").Position -= 1
    End Sub

    Private Sub mmuNavigateNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuNavigateNext.Click
        Me.BindingContext(DsParts1, "tblparts").Position += 1
    End Sub

    Private Sub mmuNavigateLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuNavigateLast.Click
        Me.BindingContext(DsParts1, "tblparts").Position = _
            Me.DsParts1.tblParts.Rows.Count - 1
    End Sub

    Private Sub EditState(ByVal pblnState As Boolean)
        Select Case pblnState
            Case cblnEditing
                mmuFile.Enabled = True
                mmuEditAdd.Enabled = False
                mmuEditEdit.Enabled = False
                mmuEditCancel.Enabled = True
                mmuEditUpdate.Enabled = True
                mmuEditDelete.Enabled = False

                txtPartNumber.Enabled = True
                txtDescription.Enabled = True
                txtQuantityOnHand.Enabled = True
                txtCost.Enabled = True
                txtSalesPrice.Enabled = True
                txtGrossProfit.Enabled = True
                txtTotalInvCost.Enabled = True
               
            Case cblnNotEditing
                mmuFile.Enabled = True
                mmuEditAdd.Enabled = True
                mmuEditEdit.Enabled = True
                mmuEditCancel.Enabled = False
                mmuEditUpdate.Enabled = False
                mmuEditDelete.Enabled = True

                txtPartNumber.Enabled = False
                txtDescription.Enabled = False
                txtQuantityOnHand.Enabled = False
                txtCost.Enabled = False
                txtSalesPrice.Enabled = False
                txtGrossProfit.Enabled = False
                txtTotalInvCost.Enabled = False
               
        End Select

    End Sub
End Class
0
 
LVL 9

Expert Comment

by:Lacutah
ID: 13412958
Here's what you need to add to bind a label's text to the text from a text box.  My label in this example is called "Label1" and the textbox is called TextBox1:

Label1.DataBindings.Add("text", textBox1, "Text")

0
 
LVL 9

Accepted Solution

by:
Lacutah earned 2000 total points
ID: 13412959
You can put this in your form.Load event if you wish.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question