TAMSCODAN
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.
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
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_CustBindingNaviga tor.Bindin gSource = 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.
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_CustBindingNaviga
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
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.
ASKER
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?
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? Â
If so, how? Â
ASKER
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?
ASKER
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
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_Cu st' table. You can move, or remove it, as needed.
    Me.TCCDB_CustTableAdapter1 .Fill(Me.T CCDBDataSe tCust.TCCD B_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.F ill(Me.TCC DBDataSetT echInfo.Te ch_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.TCCDBD ataStatus. Status)
    'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
    Me.PriorityTableAdapter.Fi ll(Me.TCCD BDataSet1. 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.TCCDBDa taSet.Mode l)
Â
    '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_CustBindingNaviga tor.Bindin gSource = bs
Â
    'Use the BindingSource for the controls on your form:
    Me.IDComboBox.DataBindings .Add("Text ", bs, "ID")
Â
  End Sub
  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_Cu
    Me.TCCDB_CustTableAdapter1
    'TODO: This line of code loads data into the 'TCCDBDataSetTechInfo.Tech
    Me.Tech_InfoTableAdapter.F
    'TODO: This line of code loads data into the 'TCCDBDataStatus.Status' table. You can move, or remove it, as needed.
    Me.StatusTableAdapter.Fill
    'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
    Me.PriorityTableAdapter.Fi
    'TODO: This line of code loads data into the 'TCCDBDataSet.Model' table. You can move, or remove it, as needed.
    Me.ModelTableAdapter.Fill(
Â
    'Create a new BindingSource
    Dim bs As New BindingSource()
    bs.DataSource = Me.TCCDBDataSetCust.TCCDB_
Â
    'Use the BindindSource for the BindingNavigator:
    Me.TCCDB_CustBindingNaviga
Â
    'Use the BindingSource for the controls on your form:
    Me.IDComboBox.DataBindings
Â
  End Sub
ASKER
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.For ms"
 StackTrace:
    at System.Windows.Forms.Contr olBindings Collection .CheckDupl icates(Bin ding binding)
    at System.Windows.Forms.Bindi ng.CheckBi nding()
    at System.Windows.Forms.Bindi ng.SetBind ableCompon ent(IBinda bleCompone nt value)
    at System.Windows.Forms.Contr olBindings Collection .AddCore(B inding dataBinding)
    at System.Windows.Forms.Contr olBindings Collection .Add(Strin g propertyName, Object dataSource, String dataMember, Boolean formattingEnabled, DataSourceUpdateMode updateMode, Object nullValue, String formatString, IFormatProvider formatInfo)
    at System.Windows.Forms.Contr olBindings Collection .Add(Strin g propertyName, Object dataSource, String dataMember)
    at N_Tron_Tech_Call_Control.T CC.TCC_Loa d(Object sender, EventArgs e) in C:\Documents and Settings\santosd.M14N53XQ4 C1\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(Eve ntArgs e)
    at System.Windows.Forms.Form. OnCreateCo ntrol()
    at System.Windows.Forms.Contr ol.CreateC ontrol(Boo lean fIgnoreVisible)
    at System.Windows.Forms.Contr ol.CreateC ontrol()
    at System.Windows.Forms.Contr ol.WmShowW indow(Mess age& m)
    at System.Windows.Forms.Contr ol.WndProc (Message& m)
    at System.Windows.Forms.Scrol lableContr ol.WndProc (Message& m)
    at System.Windows.Forms.Conta inerContro l.WndProc( Message& m)
    at System.Windows.Forms.Form. WmShowWind ow(Message & m)
    at System.Windows.Forms.Form. WndProc(Me ssage& m)
    at System.Windows.Forms.Contr ol.Control NativeWind ow.OnMessa ge(Message & m)
    at System.Windows.Forms.Contr ol.Control NativeWind ow.WndProc (Message& m)
    at System.Windows.Forms.Nativ eWindow.De buggableCa llback(Int Ptr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.SafeN ativeMetho ds.ShowWin dow(Handle Ref hWnd, Int32 nCmdShow)
    at System.Windows.Forms.Contr ol.SetVisi bleCore(Bo olean value)
    at System.Windows.Forms.Form. SetVisible Core(Boole an value)
    at System.Windows.Forms.Contr ol.set_Vis ible(Boole an value)
    at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoopInner (Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoop(Int3 2 reason, ApplicationContext context)
    at System.Windows.Forms.Appli cation.Run (Applicati onContext context)
    at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.OnRun( )
    at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.DoAppl icationMod el()
    at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.Run(St ring[] commandLine)
    at N_Tron_Tech_Call_Control.M y.MyApplic ation.Main (String[] Args) in 17d14f5c-a337-4978-8281-53 493378c107 1.vb:line 81
    at System.AppDomain._nExecute Assembly(A ssembly assembly, String[] args)
    at System.AppDomain.nExecuteA ssembly(As sembly assembly, String[] args)
    at System.Runtime.Hosting.Man ifestRunne r.Run(Bool ean checkAptModel)
    at System.Runtime.Hosting.Man ifestRunne r.ExecuteA sAssembly( )
    at System.Runtime.Hosting.App licationAc tivator.Cr eateInstan ce(Activat ionContext activationContext, String[] activationCustomData)
    at System.Runtime.Hosting.App licationAc tivator.Cr eateInstan ce(Activat ionContext activationContext)
    at Microsoft.VisualStudio.Hos tingProces s.HostProc .RunUsersA ssemblyDeb ugInZone()
    at System.Threading.ThreadHel per.Thread Start_Cont ext(Object state)
    at System.Threading.Execution Context.Ru n(Executio nContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHel per.Thread Start()
Me.IDComboBox.DataBindings
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.For
 StackTrace:
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Bindi
    at System.Windows.Forms.Bindi
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at N_Tron_Tech_Call_Control.T
    at System.EventHandler.Invoke
    at System.Windows.Forms.Form.
    at System.Windows.Forms.Form.
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Scrol
    at System.Windows.Forms.Conta
    at System.Windows.Forms.Form.
    at System.Windows.Forms.Form.
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Nativ
    at System.Windows.Forms.SafeN
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Form.
    at System.Windows.Forms.Contr
    at System.Windows.Forms.Appli
    at System.Windows.Forms.Appli
    at System.Windows.Forms.Appli
    at Microsoft.VisualBasic.Appl
    at Microsoft.VisualBasic.Appl
    at Microsoft.VisualBasic.Appl
    at N_Tron_Tech_Call_Control.M
    at System.AppDomain._nExecute
    at System.AppDomain.nExecuteA
    at System.Runtime.Hosting.Man
    at System.Runtime.Hosting.Man
    at System.Runtime.Hosting.App
    at System.Runtime.Hosting.App
    at Microsoft.VisualStudio.Hos
    at System.Threading.ThreadHel
    at System.Threading.Execution
    at System.Threading.ThreadHel
In the designer, click on "IDComboBox" and look in the properties window. Â What does it say the DataSource and DataMember is?
ASKER
Data Source: TCCDB_CustBindingSource
Display Member: ID
Value Member: ID
Selected Value: (none)
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_Cu st' table. You can move, or remove it, as needed.
    Me.TCCDB_CustTableAdapter1 .Fill(Me.T CCDBDataSe tCust.TCCD B_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.F ill(Me.TCC DBDataSetT echInfo.Te ch_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.TCCDBD ataStatus. Status)
    'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
    Me.PriorityTableAdapter.Fi ll(Me.TCCD BDataSet1. 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.TCCDBDa taSet.Mode l)
    'Use the BindindSource for the BindingNavigator:
    Me.TCCDB_CustBindingNaviga tor.Bindin gSource = TCCDB_CustBindingSource
Â
  End Sub
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_Cu
    Me.TCCDB_CustTableAdapter1
    'TODO: This line of code loads data into the 'TCCDBDataSetTechInfo.Tech
    Me.Tech_InfoTableAdapter.F
    'TODO: This line of code loads data into the 'TCCDBDataStatus.Status' table. You can move, or remove it, as needed.
    Me.StatusTableAdapter.Fill
    'TODO: This line of code loads data into the 'TCCDBDataSet1.Priority' table. You can move, or remove it, as needed.
    Me.PriorityTableAdapter.Fi
    'TODO: This line of code loads data into the 'TCCDBDataSet.Model' table. You can move, or remove it, as needed.
    Me.ModelTableAdapter.Fill(
    'Use the BindindSource for the BindingNavigator:
    Me.TCCDB_CustBindingNaviga
Â
  End Sub
ASKER
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
BINGO!!!! YOU GOT IT!!!! THAT WAS IT!!!!!!!!!!!!!!!!!!!!!!!! !!!!WOOOOO HOOOOOOO 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
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
ASKER
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'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
ASKER
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 .TCCDBData SetCust.TC CDB_Cust)
But let me get you started with this:
  Me.TCCDB_CustBindingSource
  Me.TCCDB_CustTableAdapter1
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.Bindi
    'Use the BindingSource for the controls on your form:
    Me.TextBox1.DataBindings.A