frmColourName.ShowDialog()

        'adding a customer
        m_Customercount = m_Customercount + 1
        Dim drNewRow As DataRow = m_CustomerDataTable.NewRow()
        drNewRow("CustID") = m_Customercount
        drNewRow("Company") = txtCompName.Text.Trim
        drNewRow("Address") = txtAddress.Text.Trim
        drNewRow("Telephone") = txtContact.Text.Trim
        drNewRow("Address") = txtAddress.Text.Trim
        drNewRow("Email") = btnEmail.Text.Trim

        Dim counter As Integer = 0
        While counter < m_CustomerDataTable.Rows.Count
            If m_CustomerDataTable.Rows(counter)("Company") = txtCompName.Text.Trim Then
                MessageBox.Show("This company already exists")
                Exit Sub
            End If
            counter = counter + 1
        End While

        m_CustomerDataTable.Rows.Add(drNewRow)
        m_CustomerDataAdapter.Update(m_CustomerDataTable)
        'end of add

        'adding a colourcombination
        m_Colourcount = m_Colourcount + 1
        Dim drNewRow1 As DataRow = m_ColourDataTable.NewRow()
        drNewRow1("CID") = m_Colourcount
        drNewRow1("CustID") = m_Customercount
        drNewRow1("ColourName") = g_colourname

        m_ColourDataTable.Rows.Add(drNewRow1)
        m_ColourDataAdapter.Update(m_ColourDataTable)
        'end of add


        cboColourName.Enabled = True
        cboColourCode.Enabled = True
        lstColourName.Items.Add(g_colourname)
        lstColourName.SelectedItem = g_colourname


        txtCompName.Enabled = False
        txtAddress.Enabled = False
        txtContact.Enabled = False
        btnEmail.Enabled = False


        btnNewCombination.Enabled = False
    End Sub

this was working fine for quite a while
but after i made some changes to the other part of the programs which do not seem to be related to this in any way i get this error msg

cannot find column CustID

so i commented the first line of the drNewRow
thn i get the same error for the second line

cannot find column company

Recommended Answers

All 3 Replies

Where are you getting this DataTable from? Have you changed the routine you're using to get it?

datatable is module level
and i have inserted data during the load event using data adapter which is also module level

got it
the error was something entirely different
thnx for ur help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.