Link to home
Create AccountLog in
Avatar of TAMSCODAN
TAMSCODANFlag for United States of America

asked on

VB Database Navigation Control Problem

When i open up my form and my navigation toolbar is on the top of the form it always says 0. I can create new data and it saves it to the database table however if i close my form and open it back up I have the 0 of 0 data displayed on my tool bar, once i click on the + sign and create new data i save it and It is in the database, but when trying to find old data saved i can only see what i have worked with at the moment while its open. What can i do? I am using Visual Studios 2005 VB.NET and an access Database table to save my information on.
Avatar of VBRocks
VBRocks
Flag of United States of America image

Are you referring to your BindingNavigator?

You take the table you filled, then set it to a BindingSource, and use the BindingSource as the DataSource for the BindingNavigator, and all other controls on your form.

For example:

        Dim table As New DataTable()
        Dim adapter As New SqlClient.SqlDataAdapter()
        'Fill your table
        'adapter.Fill(table)

        'Create a new BindingSource
        Dim bs As New BindingSource()
        bs.DataSource = table

        'Use the BindindSource for the BindingNavigator:
        Me.BindingNavigator1.BindingSource = bs

        'Use the BindingSource for the controls on your form:
        Me.TextBox1.DataBindings.Add("Text", bs, "TableColumnNameToBindTo")

Avatar of TAMSCODAN

ASKER

My table that i want to bind my navigator is called TCCDB_Cust now below is the code for that binding navigator, what am i doing wrong?
Private Sub TCCDB_CustBindingNavigator_RefreshItems(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCCDB_CustBindingNavigator.RefreshItems
        Dim table As New DataTable()
        Dim adapter As New SqlClient.SqlDataAdapter()
        'Fill your table
        'adapter.Fill(TCCDB_Cust)
 
        'Create a new BindingSource
        Dim bs As New BindingSource()
        bs.DataSource = table
 
        'Use the BindindSource for the BindingNavigator:
        Me.TCCDB_CustBindingNavigator.BindingSource = bs
 
        'Use the BindingSource for the controls on your form:
        Me.IDComboBox.DataBindings.Add("Text", bs, "TableColumnNameToBindTo")
 
    End Sub

Open in new window

Well, several things.  

First of all, you need to put the code in the Form_Load event.

Second of all, you need to replace the item I supplied as examples with what you are using:

        'Create a new BindingSource
        Dim bs As New BindingSource()
        bs.DataSource = TCCDB_Cust
 
        'Use the BindindSource for the BindingNavigator:
        Me.TCCDB_CustBindingNavigator.BindingSource = bs

Change "TableColumnNameToBindTo" with the name of the column in the DataTable that you want to bind your combobox to.

        'Use the BindingSource for the controls on your form:
        Me.IDComboBox.DataBindings.Add("Text", bs, "ID")


Additionally, there is more to binding a combobox than just binding the Text property.  But that's a different issue.  Get your BindingNavigator working first.
I am getting this error: Error      1      Name 'TCCDB_Cust' is not declared.      

I am a novice reading and learning VB. Where do i declare this? and how should i declare it?
Are you displaying your data on your form?

If so, how?  

Basically i have muliple textboxes that I have filled out and these texboxes are bound to the same table "TCCDB_Cust". TCCDB is the name of the database and TCCDB_Cust is the table in TCCDB. All the textboxes are bound to the same TCCDB_Cust table.
Can you show me the code that performs the binding?

This is my entire code, not sure
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices
Imports System.Drawing.Printing
Imports System.Windows
 
Public Class TCC
 
    Private Sub TCC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'TCCDBDataSetCust.TCCDB_Cust' table. You can move, or remove it, as needed.
        Me.TCCDB_CustTableAdapter1.Fill(Me.TCCDBDataSetCust.TCCDB_Cust)
        'TODO: This line of code loads data into the 'TCCDBDataSetTechInfo.Tech_Info' table. You can move, or remove it, as needed.
        Me.Tech_InfoTableAdapter.Fill(Me.TCCDBDataSetTechInfo.Tech_Info)
        'TODO: This line of code loads data into the 'TCCDBDataStatus.Status' table. You can move, or remove it, as needed.
        Me.StatusTableAdapter.Fill(Me.TCCDBDataStatus.Status)
        'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
        Me.PriorityTableAdapter.Fill(Me.TCCDBDataSet1.Priority)
        'TODO: This line of code loads data into the 'TCCDBDataSet.Model' table. You can move, or remove it, as needed.
        Me.ModelTableAdapter.Fill(Me.TCCDBDataSet.Model)
        Dim table As New DataTable()
        Dim adapter As New SqlClient.SqlDataAdapter()
        'Fill your table
        'adapter.Fill(TCCDB_Cust)
 
        'Create a new BindingSource
        Dim bs As New BindingSource()
        bs.DataSource = TCCDB_Cust
 
        'Use the BindindSource for the BindingNavigator:
        Me.TCCDB_CustBindingNavigator.BindingSource = bs
 
        'Use the BindingSource for the controls on your form:
        Me.IDComboBox.DataBindings.Add("Text", bs, "ID")
 
    End Sub
 
    Private Sub TCCDB_CustBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCCDB_CustBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.TCCDB_CustBindingSource.EndEdit()
 
    End Sub
 
    Private Sub btn_Email_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Email.Click
        Dim ma As New Mapi()
        Dim subjectText As String = "Contact Info -  " & PriorityComboBox.Text & "-" & StatusComboBox.Text
        Dim bodyText As String = "Contact Info:" + Environment.NewLine
        Dim recipientAddress As String = "n-tron_support@n-tron.com"
 
        ' Urgent Email involving Management
        If chk_Urgent.Checked Then recipientAddress = "Urgent@n-tron.com"
 
        'Standard email for regions
        If rdo_Region1.Checked Then recipientAddress = ";region1@n-tron.com"
        If rdo_Region2.Checked Then recipientAddress = ";region2@n-tron.com"
        If rdo_Region3.Checked Then recipientAddress = ";region3@n-tron.com"
        If rdo_Region4.Checked Then recipientAddress = ";region4@n-tron.com"
        If rdo_Region5.Checked Then recipientAddress = ";region5@n-tron.com"
        If rdo_Region6.Checked Then recipientAddress = ";region6@n-tron.com"
        If rdo_Region7.Checked Then recipientAddress = ";region7@n-tron.com"
        'defines the information in the body of the e-mail
        bodyText &= "Status: " & StatusComboBox.Text & Environment.NewLine + Environment.NewLine
        bodyText &= "First Name: " & Tbl_CustFirstNameTextBox.Text & Environment.NewLine
        bodyText &= "Last Name: " & Tbl_CustLastNameTextBox.Text & Environment.NewLine
        bodyText &= "Company: " & Tbl_CompanyTextBox.Text & Environment.NewLine
        bodyText &= "Address: " & Tbl_AddressTextBox.Text & Environment.NewLine
        bodyText &= "Telephone Number: " & Tbl_TelephoneNumTextBox.Text & Environment.NewLine + Environment.NewLine
        bodyText &= "Model: " & ModelComboBox.Text & Environment.NewLine
        bodyText &= "Customer Notes: " & Customer_NotesTextBox.Text & Environment.NewLine + Environment.NewLine
 
        bodyText &= "Tech Notes: " & Tech_NotesTextBox.Text & Environment.NewLine + Environment.NewLine
        bodyText &= "Tech Info: " & Tech_InfoComboBox.Text & Environment.NewLine + Environment.NewLine
        ma.AddRecip(recipientAddress, "", False)
        If (Not ma.Send(subjectText, bodyText)) Then _
            MessageBox.Show(Me, "MAPISendMail failed! " + ma.ErrorMessage(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning)
 
        ma.Reset()
        Me.Close()
    End Sub
 
    Private Sub btn_Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Close.Click
        Close()
    End Sub
 
    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
 
    End Sub
 
    Private Sub btn_Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Print.Click
        ' Create object, passing in text
        Dim bodyText As String = "Contact Info:" + Environment.NewLine
        Dim MyPrintObject As New TextPrint(Tbl_CompanyTextBox.Text)
        ' Set font, if required
        MyPrintObject.Font = New Font("Tahoma", 8)
        ' Issue print command
 
 
        MyPrintObject.Print()
 
    End Sub
 
    Private Sub Find_CustToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub FindToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub Find_DataToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub Find_DataToolStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)
 
    End Sub
 
    Private Sub FindToolStripButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Me.TCCDB_CustTableAdapter.Find(Me.TCCDBDataSet.TCCDB_Cust)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
 
    End Sub
 
    Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByToolStripButton.Click
        Try
            Me.TCCDB_CustTableAdapter.FillBy(Me.TCCDBDataSet.TCCDB_Cust)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub TCCDB_CustBindingNavigator_RefreshItems(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCCDB_CustBindingNavigator.RefreshItems
 
    End Sub
 
    Private Sub BindingNavigatorPositionItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorPositionItem.Click
 
    End Sub
 
    Private Sub Tbl_CompanyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbl_CompanyTextBox.TextChanged
 
    End Sub
End Class
Public Class Mapi
 
    Private Const MapiORIG As Integer = 0
    Private Const MapiTO As Integer = 1
    Private Const MapiCC As Integer = 2
 
    Private err As Integer = 0
    Private lastMsg As MapiMessage = Nothing
    Private origin As New MapiRecipDesc()
    Private recpts As New ArrayList()
    Private session As IntPtr = IntPtr.Zero
    Private winhandle As IntPtr = IntPtr.Zero
 
    Private ReadOnly errors As String() = New String() {"OK [0]", "User abort [1]", "General MAPI failure [2]", "MAPI login failure [3]", "Disk full [4]", "Insufficient memory [5]", _
     "Access denied [6]", "-unknown- [7]", "Too many sessions [8]", "Too many files were specified [9]", "Too many recipients were specified [10]", "A specified attachment was not found [11]", _
     "Attachment open failure [12]", "Attachment write failure [13]", "Unknown recipient [14]", "Bad recipient type [15]", "No messages [16]", "Invalid message [17]", _
     "Text too large [18]", "Invalid session [19]", "Type not supported [20]", "A recipient was specified ambiguously [21]", "Message in use [22]", "Network failure [23]", _
     "Invalid edit fields [24]", "Invalid recipients [25]", "Not supported [26]"}
 
    <DllImport("MAPI32.DLL")> _
    Private Shared Function MAPISendMail(ByVal sess As IntPtr, ByVal hwnd As IntPtr, ByVal message As MapiMessage, ByVal flg As Integer, ByVal rsv As Integer) As Integer
    End Function
 
    Public Sub AddRecip(ByVal name As String, ByVal addr As String, ByVal cc As Boolean)
        Dim dest As New MapiRecipDesc()
        If cc Then
            dest.recipClass = MapiCC
        Else
            dest.recipClass = MapiTO
        End If
        dest.name = name
        dest.address = addr
        recpts.Add(dest)
    End Sub
 
    Private Function AllocOrigin() As IntPtr
        origin.recipClass = MapiORIG
        Dim rtype As Type = GetType(MapiRecipDesc)
        Dim rsize As Integer = Marshal.SizeOf(rtype)
        Dim ptro As IntPtr = Marshal.AllocHGlobal(rsize)
        Marshal.StructureToPtr(origin, ptro, False)
        Return ptro
    End Function
 
    Private Function AllocRecips(ByRef recipCount As Integer) As IntPtr
        recipCount = 0
        If recpts.Count = 0 Then
            Return IntPtr.Zero
        End If
 
        Dim rtype As Type = GetType(MapiRecipDesc)
        Dim rsize As Integer = Marshal.SizeOf(rtype)
        Dim ptrr As IntPtr = Marshal.AllocHGlobal(recpts.Count * rsize)
 
        Dim runptr As Integer = CInt(ptrr)
        For i As Integer = 0 To recpts.Count - 1
            Marshal.StructureToPtr(TryCast(recpts(i), MapiRecipDesc), CType(runptr, IntPtr), False)
            runptr += rsize
        Next
 
        recipCount = recpts.Count
        Return ptrr
    End Function
 
    Private Sub Dealloc()
        Dim rtype As Type = GetType(MapiRecipDesc)
        Dim rsize As Integer = Marshal.SizeOf(rtype)
 
        If lastMsg.originator <> IntPtr.Zero Then
            Marshal.DestroyStructure(lastMsg.originator, rtype)
            Marshal.FreeHGlobal(lastMsg.originator)
        End If
 
        If lastMsg.recips <> IntPtr.Zero Then
            Dim runptr As Integer = CInt(lastMsg.recips)
            For i As Integer = 0 To lastMsg.recipCount - 1
                Marshal.DestroyStructure(CType(runptr, IntPtr), rtype)
                runptr += rsize
            Next
            Marshal.FreeHGlobal(lastMsg.recips)
        End If
    End Sub
 
    Public Function ErrorMessage() As String
        If err <= 26 Then
            Return errors(err)
        End If
        Return err.ToString()
    End Function
 
    Public Sub Reset()
        origin = New MapiRecipDesc()
        recpts.Clear()
        lastMsg = Nothing
    End Sub
 
    Public Function Send(ByVal [sub] As String, ByVal txt As String) As Boolean
        lastMsg = New MapiMessage()
        lastMsg.subject = [sub]
        lastMsg.noteText = txt
 
        ' set pointers
        lastMsg.originator = AllocOrigin()
        lastMsg.recips = AllocRecips(lastMsg.recipCount)
        err = MAPISendMail(session, winhandle, lastMsg, 0, 0)
        Dealloc()
        Reset()
        Return err = 0
 
    End Function
 
    Public Sub SetSender(ByVal sname As String, ByVal saddr As String)
        origin.name = sname
        origin.address = saddr
    End Sub
 
End Class
 
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Class MapiMessage
    Public reserved As Integer
    Public subject As String
    Public noteText As String
    Public messageType As String
    Public dateReceived As String
    Public conversationID As String
    Public flags As Integer
    Public originator As IntPtr
    ' MapiRecipDesc* [1]
    Public recipCount As Integer
    Public recips As IntPtr
    ' MapiRecipDesc* [n]
    Public fileCount As Integer
    Public files As IntPtr
    ' MapiFileDesc*  [n]
End Class
 
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Class MapiRecipDesc
    Public reserved As Integer
    Public recipClass As Integer
    Public name As String
    Public address As String
    Public eIDSize As Integer
    Public entryID As IntPtr
    ' void*
End Class
 
Public Class TextPrint
    ' Inherits all the functionality of a PrintDocument
    Inherits Printing.PrintDocument
    ' Private variables to hold default font and text
    Private fntPrintFont As Font
    Private strText As String
    Public Sub New(ByVal Text As String)
        ' Sets the file stream
        MyBase.New()
        strText = Text
    End Sub
    Public Property Text() As String
        Get
            Return strText
        End Get
        Set(ByVal Value As String)
            strText = Value
        End Set
    End Property
    Protected Overrides Sub OnBeginPrint(ByVal ev _
                                As Printing.PrintEventArgs)
        ' Run base code
        MyBase.OnBeginPrint(ev)
        ' Sets the default font
        If fntPrintFont Is Nothing Then
            fntPrintFont = New Font("Times New Roman", 12)
        End If
    End Sub
    Public Property Font() As Font
        ' Allows the user to override the default font
        Get
            Return fntPrintFont
        End Get
        Set(ByVal Value As Font)
            fntPrintFont = Value
        End Set
    End Property
    Protected Overrides Sub OnPrintPage(ByVal ev _
       As Printing.PrintPageEventArgs)
        ' Provides the print logic for our document
 
        ' Run base code
        MyBase.OnPrintPage(ev)
        ' Variables
        Static intCurrentChar As Integer
        Dim intPrintAreaHeight, intPrintAreaWidth, _
            intMarginLeft, intMarginTop As Integer
        ' Set printing area boundaries and margin coordinates
        With MyBase.DefaultPageSettings
            intPrintAreaHeight = .PaperSize.Height - _
                               .Margins.Top - .Margins.Bottom
            intPrintAreaWidth = .PaperSize.Width - _
                              .Margins.Left - .Margins.Right
            intMarginLeft = .Margins.Left 'X
            intMarginTop = .Margins.Top   'Y
        End With
        ' If Landscape set, swap printing height/width
        If MyBase.DefaultPageSettings.Landscape Then
            Dim intTemp As Integer
            intTemp = intPrintAreaHeight
            intPrintAreaHeight = intPrintAreaWidth
            intPrintAreaWidth = intTemp
        End If
        ' Calculate total number of lines
        Dim intLineCount As Int32 = _
                CInt(intPrintAreaHeight / Font.Height)
        ' Initialise rectangle printing area
        Dim rectPrintingArea As New RectangleF(intMarginLeft, _
            intMarginTop, intPrintAreaWidth, intPrintAreaHeight)
        ' Initialise StringFormat class, for text layout
        Dim objSF As New StringFormat(StringFormatFlags.LineLimit)
        ' Figure out how many lines will fit into rectangle
        Dim intLinesFilled, intCharsFitted As Int32
        ev.Graphics.MeasureString(Mid(strText, _
                    UpgradeZeros(intCurrentChar)), Font, _
                    New SizeF(intPrintAreaWidth, _
                    intPrintAreaHeight), objSF, _
                    intCharsFitted, intLinesFilled)
        ' Print the text to the page
        ev.Graphics.DrawString(Mid(strText, _
            UpgradeZeros(intCurrentChar)), Font, _
            Brushes.Black, rectPrintingArea, objSF)
        ' Increase current char count
        intCurrentChar += intCharsFitted
        ' Check whether we need to print more
        If intCurrentChar < strText.Length Then
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
            intCurrentChar = 0
        End If
    End Sub
    Public Function UpgradeZeros(ByVal Input As Integer) As Integer
        ' Upgrades all zeros to ones
        ' - used as opposed to defunct IIF or messy If statements
        If Input = 0 Then
            Return 1
        Else
            Return Input
        End If
    End Function
   
End Class

Open in new window

Use this:

    Private Sub TCC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'TCCDBDataSetCust.TCCDB_Cust' table. You can move, or remove it, as needed.
        Me.TCCDB_CustTableAdapter1.Fill(Me.TCCDBDataSetCust.TCCDB_Cust)
        'TODO: This line of code loads data into the 'TCCDBDataSetTechInfo.Tech_Info' table. You can move, or remove it, as needed.
        Me.Tech_InfoTableAdapter.Fill(Me.TCCDBDataSetTechInfo.Tech_Info)
        'TODO: This line of code loads data into the 'TCCDBDataStatus.Status' table. You can move, or remove it, as needed.
        Me.StatusTableAdapter.Fill(Me.TCCDBDataStatus.Status)
        'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
        Me.PriorityTableAdapter.Fill(Me.TCCDBDataSet1.Priority)
        'TODO: This line of code loads data into the 'TCCDBDataSet.Model' table. You can move, or remove it, as needed.
        Me.ModelTableAdapter.Fill(Me.TCCDBDataSet.Model)

 
        'Create a new BindingSource
        Dim bs As New BindingSource()
        bs.DataSource = Me.TCCDBDataSetCust.TCCDB_Cust   '< changed this
 
        'Use the BindindSource for the BindingNavigator:
        Me.TCCDB_CustBindingNavigator.BindingSource = bs
 
        'Use the BindingSource for the controls on your form:
        Me.IDComboBox.DataBindings.Add("Text", bs, "ID")
 
    End Sub

This is the exception that I am getting now: ont this line when i run the debug:
Me.IDComboBox.DataBindings.Add("Text", bs, "ID")


System.ArgumentException was unhandled
  Message="This causes two bindings in the collection to bind to the same property.
Parameter name: binding"
  ParamName="binding"
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.ControlBindingsCollection.CheckDuplicates(Binding binding)
       at System.Windows.Forms.Binding.CheckBinding()
       at System.Windows.Forms.Binding.SetBindableComponent(IBindableComponent value)
       at System.Windows.Forms.ControlBindingsCollection.AddCore(Binding dataBinding)
       at System.Windows.Forms.ControlBindingsCollection.Add(String propertyName, Object dataSource, String dataMember, Boolean formattingEnabled, DataSourceUpdateMode updateMode, Object nullValue, String formatString, IFormatProvider formatInfo)
       at System.Windows.Forms.ControlBindingsCollection.Add(String propertyName, Object dataSource, String dataMember)
       at N_Tron_Tech_Call_Control.TCC.TCC_Load(Object sender, EventArgs e) in C:\Documents and Settings\santosd.M14N53XQ4C1\My Documents\Visual Studio 2005\Projects\N-Tron Tech Call Control\N-Tron Tech Call Control\TCC.vb:line 30
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at N_Tron_Tech_Call_Control.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
In the designer, click on "IDComboBox" and look in the properties window.  What does it say the DataSource and DataMember is?


Data Source: TCCDB_CustBindingSource
Display Member: ID
Value Member: ID
Selected Value: (none)
Oooooo....  Do you see that?  It's datasource is a BindingSource. That means you don't have to create one.

I'll bet this will work:

   Private Sub TCC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'TCCDBDataSetCust.TCCDB_Cust' table. You can move, or remove it, as needed.
        Me.TCCDB_CustTableAdapter1.Fill(Me.TCCDBDataSetCust.TCCDB_Cust)
        'TODO: This line of code loads data into the 'TCCDBDataSetTechInfo.Tech_Info' table. You can move, or remove it, as needed.
        Me.Tech_InfoTableAdapter.Fill(Me.TCCDBDataSetTechInfo.Tech_Info)
        'TODO: This line of code loads data into the 'TCCDBDataStatus.Status' table. You can move, or remove it, as needed.
        Me.StatusTableAdapter.Fill(Me.TCCDBDataStatus.Status)
        'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
        Me.PriorityTableAdapter.Fill(Me.TCCDBDataSet1.Priority)
        'TODO: This line of code loads data into the 'TCCDBDataSet.Model' table. You can move, or remove it, as needed.
        Me.ModelTableAdapter.Fill(Me.TCCDBDataSet.Model)


        'Use the BindindSource for the BindingNavigator:
        Me.TCCDB_CustBindingNavigator.BindingSource = TCCDB_CustBindingSource
 
    End Sub

For some reason it is not displaying that data in the tables already when i run the debugger. Clean and no errors but it wond show the records already in the table
ASKER CERTIFIED SOLUTION
Avatar of VBRocks
VBRocks
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
BINGO!!!! YOU GOT IT!!!! THAT WAS IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!WOOOOOHOOOOOOO THANK YOU SOOO MUCH!!!

Can you help me fix my print button. I want it to print the data of each record. Someone told me to use the printform but i just want to print the data from the same table. DOnt worry gonna give you the 500 pts :) Thank you sooo much
Thank you for all your help!!! Your goood. I ma trying to get there!!!!
Whoa!  You're pretty excited!  (just teasing)

I'm glad I could help.  

To answer your printing question, you're probably going to have to create a Crystal Report.  They are pretty easy to create and run.  Take a look at this question I answered, it has a walk-through on how to do this:

    https://www.experts-exchange.com/questions/23270205/Data-Retreival-from-two-databases.html

I was going through the form and it worked were i can look at all the tables i had however when i add a table it doesnt save in the database not at all. Can you please help me?
Database updates are total different topic, and they can be pretty involved.  I would recommend opening a different question for that.

But let me get you started with this:

    Me.TCCDB_CustBindingSource.EndEdit()
    Me.TCCDB_CustTableAdapter1.Update(Me.TCCDBDataSetCust.TCCDB_Cust)