troubleshooting Question

Getting "Cannot update identity column" error when I'm not trying to update an identity column

Avatar of megnin
megninFlag for United States of America asked on
Microsoft SQL Server.NET ProgrammingVisual Basic.NET
12 Comments1 Solution2323 ViewsLast Modified:
In a VB Windows app I'm getting a "Cannot update identity column 'keyJobTitleID'" and I'm not trying to update the identity column 'keyJobTitleID'.
The error is falling on the line immediately preceding End Sub here:
    Private Sub updateTotals()
        If cmJobs.Count = 0 Then
            txtAvailable.Text = ""
            txtTaken.Text = ""
            txtTotal.Text = ""
            MsgBox("No more jobs")
            Exit Sub
        End If
        'use the currency manager to get the currently ...
        '... selected job in the jobs grid
        Dim jobsRow As DataRowView = CType(cmJobs.Current, DataRowView)
        'that says how many of that job are available
        Dim available As Integer = CInt(jobsRow.Item("txtWorksiteJobTitlePositionsNumber"))
        'get the job ID from that row
        Dim thisJob As Integer = CInt(jobsRow.Item("keyJobTitleID"))
        'use the job ID to find how many applicants ...
        '... already have that job
        Dim taken As Integer = CInt(dtApplicants.Compute("Count(keyJobTitleID)", "keyJobTitleID = " & thisJob))
        'the total is the sum of those two
        Dim total As Integer = available + taken
        'display the results
        txtAvailable.Text = available.ToString
        txtTaken.Text = taken.ToString
        txtTotal.Text = total.ToString

        'update TextBoxes for count of SYEP, STEPS and Fort Lauderdale Kids - IN Form_Load, UpdateTotals and btnRefresh_Click
        txtSYEP.Text = Me.ApplicantsTableAdapter.CountSYEPActivity().ToString
        txtSTEPS.Text = Me.ApplicantsTableAdapter.CountSTEPSActivity().ToString
        txtFTLauderdale.Text = Me.ApplicantsTableAdapter.CountFtLauderdaleActivity().ToString
        txtConsideredCount.Text = Me.ApplicantsTableAdapter.CountConsidered().ToString

        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)   '<-- Error: Cannot update Identity column 'keyJobTitleID'
    End Sub

The above sub is called when I make a change in the DataGridView by this sub:
    Private Sub cmJobs_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmJobs.PositionChanged
        'the jobs currency manager was declared WithEvents ...
        '... to make it easy to update the jobs numbers ...
        '... displays when a different job was selected ...
        '... in the grid
        If cmJobs.Count > 0 Then
            updateTotals()
        End If
    End Sub

The JobTitlesTableAdapter has this SQL CommandText:
SELECT     COUNT(*) AS Expr1
FROM         JobTitles INNER JOIN
                      Worksites ON JobTitles.keyWorksiteID = Worksites.keyWorksiteID

The ApplicantsTableAdapter has this stored procedure:
ALTER PROCEDURE [dbo].[spUpdate_Applicants_WorksiteName_From_JobTitles] AS
UPDATE Applicants  
SET keyWorksiteID = J.keyWorksiteID,
      keyEmployerID = J.keyEmployerID,
      WorksiteName = J.WorksiteName,
      EmployerName = J.EmployerName
FROM Applicants  A
INNER JOIN JobTitles J
ON A.keyJobTitleID = J.keyJobTitleID

and some select and count statements.

In the Applicants table the Identity column is "keyApplicantID", in the JobTitles table the Identity column is "keyJobTitleID".

I'm not trying to change the keyJobTitleID field in JobTitles, I'm basically copying the value into the Forein Key field with the same name, "keyJobTitleID" in the Applicants table, then updating some totals in the JobTitles table.  The purpose is to copy into or "assign" JobTitle IDs to the Applicants table FK, "keyJobTitleID".

It was working during the time I was generating my own PKs with the columns set to Identity=No.  I started getting this error when I changed the PK, "keyJobTitleID" etc. to Identity=Yes.

The error appears on line 248 when I make a JobTitle assignment, see "Private Sub cmJobs_PositionChanged".

Any help is greatly apprecited.  I'm learning and don't know what I'm doing. :-}


Imports System
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.Windows.Forms
Imports System.Drawing
 
Public Class YouthJob
    Private dtApplicants As DataTable
    Private cmApplicants As CurrencyManager
    Private dtJobs As DataTable
    Private dvjobs As New DataView
    Private WithEvents cmJobs As CurrencyManager
 
    Private Sub ApplicantsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApplicantsBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.ApplicantsBindingSource.EndEdit()
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
    End Sub
 
    Private Sub YouthJob_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SYEP2007DataSet.JobTitles' table. You can move, or remove it, as needed.
        'Me.JobTitlesTableAdapter.Fill(Me.SYEP2007DataSet.JobTitles)
        'Me.ApplicantsTableAdapter.Fill(Me.SYEP2007DataSet.Applicants)
        Try
            Me.JobTitlesTableAdapter.Fill(Me.SYEP2007DataSet.JobTitles)
        Catch ex As Exception
            MessageBox.Show(ex.StackTrace)
        End Try
        Try
            Me.ApplicantsTableAdapter.Fill(Me.SYEP2007DataSet.Applicants)
        Catch ex As Exception
            MessageBox.Show(ex.StackTrace)
        End Try
 
 
 
        dtApplicants = Me.SYEP2007DataSet.Applicants
        dtJobs = Me.SYEP2007DataSet.JobTitles
 
        'filltables() 'equivalent to filling tables with ...
        '... a dataadapter or a tableadapter
 
        'get and display the count of applicant records
        Dim count As Integer = dtApplicants.Rows.Count
        txtTotalApplicants.Text = String.Format("{0} Applicants", count)
 
        'TabControl1.SelectedIndex = 1    'Commented out.  There's no TabControl on this form.  Just on the original Form1
 
        'bind the applicants table to the datagridview
        ApplicantsDataGridView.DataSource = dtApplicants
        'set up the currencymanager - convenient for referring ...
        '... to the currently selected row in the applicants grid
        cmApplicants = CType(BindingContext(dtApplicants), CurrencyManager)
 
        'set up a dataview to filter the jobs table so it ...
        '... only shows those where some jobs remain available
        dvjobs.Table = dtJobs
        'dvjobs.RowFilter = "txtWorksiteJobTitlePositionsNumber > 0"         '<<<<<Moved to end of YouthJob_Load
        'bind the jobs table to the datagridview
        JobTitlesDataGridView.DataSource = dvjobs
        'set up the currency manager
        cmJobs = CType(BindingContext(dvjobs), CurrencyManager)
 
        'customise the grids - with a strongly typed dataset ...
        '... this could be done in the designer
        ApplicantsDataGridView.ReadOnly = False
        ApplicantsDataGridView.AllowUserToAddRows = False   'Was True.  I don't know why.
        'hide the applicant ID
        ApplicantsDataGridView.Columns(0).Visible = True
        'hide the job ID ...
        ApplicantsDataGridView.Columns(1).Visible = True
        'hide the ProgramID column in Applicants DGV
        ApplicantsDataGridView.Columns(3).Visible = True
        '... but add an unbound column to show ...
        '... the job title matching that ID
        Dim TitleCol As New DataGridViewTextBoxColumn
        'TitleCol.HeaderText = "Job Title"
 
        'ApplicantsDataGridView.Columns(0).Width = 50  'AppID
        'ApplicantsDataGridView.Columns(1).Width = 50  'JobTitleID
        'ApplicantsDataGridView.Columns(2).Width = 100  'LastName
        'ApplicantsDataGridView.Columns(3).Width = 100  'FirstName
        'ApplicantsDataGridView.Columns(4).Width = 150  'Home City
        'ApplicantsDataGridView.Columns(5).Width = 60  'Zip
        'ApplicantsDataGridView.Columns(6).Width = 150  'City Preference
        'ApplicantsDataGridView.Columns(7).Width = 60  'Hours
        'ApplicantsDataGridView.Columns(8).Width = 50  'M-F
        ApplicantsDataGridView.Columns.Add("TitleCol", "Job Title")
        ApplicantsDataGridView.Columns("TitleCol").DisplayIndex = 9
        'ApplicantsDataGridView.Columns("TitleCol").Width = 250  'Job Title
        'ApplicantsDataGridView.Columns(10).Width = 200  'Work Preference
        'ApplicantsDataGridView.Columns(11).Width = 95  'Referred by
        'ApplicantsDataGridView.Columns(12).Width = 50  'Offender
 
        'Dim NumberofAdults As New DataGridViewTextBoxColumn  'Adding column this way did not show any data
        'NumberofAdults.HeaderText = "Adults"                 'Adding it in the designer shows the data
        'ApplicantsDataGridView.Columns.Add(NumberofAdults)   'The above Titlecol column goes on the end
 
        JobTitlesDataGridView.ReadOnly = True
        JobTitlesDataGridView.AllowUserToAddRows = False
        'JobTitlesDataGridView.Columns(0).Visible = False  'Hide JobTitleID
 
 
        'run the sub to fill the jobs numbers displays
        updateTotals()
 
        'get the job titles for the applicants
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            'cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE 'This had no apparent affect.  It didn't cause the Job Title column to fill in on form load
            'ApplicantsDataGridView.EndEdit()  'This didn't do it either.
 
        Next
        dvjobs.RowFilter = "txtWorksiteJobTitlePositionsNumber > 0"   '<<<<<Moved to end of YouthJob_Load from above.
 
        'update TextBoxes for count of SYEP, STEPS and Fort Lauderdale Kids - IN Form_Load, UpdateTotals and btnRefresh_Click
        txtSYEP.Text = Me.ApplicantsTableAdapter.CountSYEPActivity().ToString
        txtSTEPS.Text = Me.ApplicantsTableAdapter.CountSTEPSActivity().ToString
        txtFTLauderdale.Text = Me.ApplicantsTableAdapter.CountFtLauderdaleActivity().ToString
        txtConsideredCount.Text = Me.ApplicantsTableAdapter.CountConsidered().ToString
 
    End Sub
    Private Sub YouthJob_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)
 
    End Sub
    Private Sub btnUpdatePosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdatePosition.Click
 
        Dim jobRow As DataRow()
        'use the currency manager to get the currently ...
        '... selected job in the jobs grid
        Dim jobsRow As DataRowView = CType(cmJobs.Current, DataRowView)
        'and save the job number
        Dim newJobNumber As Integer = CInt(jobsRow("keyJobTitleID"))
        'similar for the applicants
        Dim applicantsRow As DataRowView = CType(cmApplicants.Current, DataRowView)
        'check if this applicant already has a job
        If Not TypeOf (applicantsRow.Item("keyJobTitleID")) Is DBNull Then
            'if so, seek the relevant row from the datatable
            jobRow = dtJobs.Select("keyJobTitleID = " & Convert.ToString(applicantsRow.Item("keyJobTitleID")))
            'if there is one
            If jobRow.Length > 0 Then
                'it will be the first in the row array: update it
                Dim myVal As Integer = CInt(jobRow(0).Item("txtWorksiteJobTitlePositionsNumber"))
                myVal += 1 'or myVal = myVal + 1
                jobRow(0).Item("txtWorksiteJobTitlePositionsNumber") = myVal
            Else
                'if there isn't one ...
                MsgBox("Something wrong")
            End If
        End If
        'put the new job number in the applicant's record
        applicantsRow.Item("keyJobTitleID") = newJobNumber
        'decrement the number of jobs available
        'seek the relevant row from the datatable
        jobRow = dtJobs.Select("keyJobTitleID = " & newJobNumber)
        'if there is one
        If jobRow.Length > 0 Then
            'it will be the first in the row array: update it
            Dim myVal As Integer = CInt(jobRow(0).Item("txtWorksiteJobTitlePositionsNumber"))
            myVal -= 1 'or myVal = myVal - 1
            jobRow(0).Item("txtWorksiteJobTitlePositionsNumber") = myVal
        Else
            'if there isn't one ...
            MsgBox("Something wrong")
        End If
 
        ''commit the edits - this is necessary where ...
        ''... they have been done by via the currency ...
        ''... manager's Current record, rather than ...
        ''... (as above) in the datatable itself
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
 
        'run the sub to update the jobs numbers displays
        updateTotals()
 
        'get the job title for this applicant
        Dim dgvr As DataGridViewRow = ApplicantsDataGridView.CurrentRow
        fillInTitle(dgvr)
 
        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)
 
 
    End Sub
 
    Private Sub btnCancelPosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelPosition.Click
        Me.Close()
    End Sub
 
    Private Sub cmJobs_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmJobs.PositionChanged
        'the jobs currency manager was declared WithEvents ...
        '... to make it easy to update the jobs numbers ...
        '... displays when a different job was selected ...
        '... in the grid
        If cmJobs.Count > 0 Then
            updateTotals()
        End If
    End Sub
 
    Private Sub updateTotals()
        If cmJobs.Count = 0 Then
            txtAvailable.Text = ""
            txtTaken.Text = ""
            txtTotal.Text = ""
            MsgBox("No more jobs")
            Exit Sub
        End If
        'use the currency manager to get the currently ...
        '... selected job in the jobs grid
        Dim jobsRow As DataRowView = CType(cmJobs.Current, DataRowView)
        'that says how many of that job are available
        Dim available As Integer = CInt(jobsRow.Item("txtWorksiteJobTitlePositionsNumber"))
        'get the job ID from that row
        Dim thisJob As Integer = CInt(jobsRow.Item("keyJobTitleID"))
        'use the job ID to find how many applicants ...
        '... already have that job
        Dim taken As Integer = CInt(dtApplicants.Compute("Count(keyJobTitleID)", "keyJobTitleID = " & thisJob))
        'the total is the sum of those two
        Dim total As Integer = available + taken
        'display the results
        txtAvailable.Text = available.ToString
        txtTaken.Text = taken.ToString
        txtTotal.Text = total.ToString
 
        'update TextBoxes for count of SYEP, STEPS and Fort Lauderdale Kids - IN Form_Load, UpdateTotals and btnRefresh_Click
        txtSYEP.Text = Me.ApplicantsTableAdapter.CountSYEPActivity().ToString
        txtSTEPS.Text = Me.ApplicantsTableAdapter.CountSTEPSActivity().ToString
        txtFTLauderdale.Text = Me.ApplicantsTableAdapter.CountFtLauderdaleActivity().ToString
        txtConsideredCount.Text = Me.ApplicantsTableAdapter.CountConsidered().ToString
 
        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)
    End Sub
 
    Private Function getTitleFromID(ByVal ID As Integer) As String
        'Temporary line for debugging purposes
        'If that is reporting 0, then we know the problem is with the datatable.  
        'If it is reporting more than that, then the problem is with either the value 
        'that is being passed to the function, 
        'or with the syntax or references in the select statement.
        'Debug.WriteLine(dtJobs.Rows.Count)
 
        'use datatable filter to return only rows with this ID
        Dim dr As DataRow() = dtJobs.Select("keyJobTitleID = " & ID)
        'check if there are any such rowsI
        If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobName field from that
            '          Return CStr(dr(0)("txtWorksiteJobTitle"))
            Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
            ' MsgBox("| s = " & s & "|")  'Here for troubleshooting
            Return s
        Else
            'otherwise, return empty string
            Return ""
        End If
    End Function
 
    Private Sub fillInTitle(ByVal dgvr As DataGridViewRow)
        'check if there is a value in the third cell ...
        '... (index 2, which is the "Job" field ...
        '... in this row from the datagridview
        If TypeOf dgvr.Cells("keyJobTitleID").Value Is DBNull Then
            'if not, then there is no Job Title
            dgvr.Cells("TitleCol").Value = ""
        Else
            'if there is, use it to get the Job Title
            'Debug.WriteLine("Cell 2 = " & CInt(dgvr.Cells(2).Value))  'I didn't see anything unusual in the debug window when this ran.
            'MsgBox("Cell 2 = " & CInt(dgvr.Cells(2).Value))  '  Here for troubleshooting.
            dgvr.Cells("TitleCol").Value = getTitleFromID(CInt(dgvr.Cells("keyJobTitleID").Value))
            'Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'")
            'MsgBox("Cell 4 = '" & CStr(dgvr.Cells(4).Value) & "'")   'Here for troubleshooting.
            'MsgBox("Cell 4 = '" & CStr(dgvr.Cells("TitleCol").Value) & "'")
        End If
 
 
    End Sub
 
    Private Sub ApplicantsDataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles ApplicantsDataGridView.DataError
        Debug.WriteLine(e.ColumnIndex)
        Debug.WriteLine(e.RowIndex)
        Debug.WriteLine(ApplicantsDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
        Debug.WriteLine(ApplicantsDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).EditedFormattedValue)
        e.ThrowException = True
    End Sub
 
    Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
        ''get the job titles for the applicants
        ''I copied this from the bottom of YouthJob_Load in an attempt to make the Applicants DGV update the Job Titles after a column sort.
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            'cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE 'This had no apparent affect.  It didn't cause the Job Title column to fill in on form load
            'ApplicantsDataGridView.EndEdit()  'This didn't do it either.
        Next
 
        'update TextBoxes for count of SYEP, STEPS and Fort Lauderdale Kids - IN Form_Load, UpdateTotals and btnRefresh_Click
        txtSYEP.Text = Me.ApplicantsTableAdapter.CountSYEPActivity().ToString
        txtSTEPS.Text = Me.ApplicantsTableAdapter.CountSTEPSActivity().ToString
        txtFTLauderdale.Text = Me.ApplicantsTableAdapter.CountFtLauderdaleActivity().ToString
        txtConsideredCount.Text = Me.ApplicantsTableAdapter.CountConsidered().ToString
 
        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)
 
        'Update Applicants(keyWorksiteID, keyEmployerID, WorksiteName, EmployerName) from JobTitles(keyWorksiteID, keyEmployerID, WorksiteName, EmployerName) in the database tables
        Try
            Me.ApplicantsTableAdapter.spUpdate_Applicants_WorksiteName_From_JobTitles()
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
    Private Sub ApplicantsDataGridView_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles ApplicantsDataGridView.ColumnHeaderMouseClick
        ''get the job titles for the applicants
        ''I copied this from the bottom of YouthJob_Load in an attempt to make the Applicants DGV update the Job Titles after a column sort.
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            'cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE 'This had no apparent affect.  It didn't cause the Job Title column to fill in on form load
            'ApplicantsDataGridView.EndEdit()  'This didn't do it either.
        Next
 
    End Sub
    Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByToolStripButton.Click
        Try
            Me.ApplicantsTableAdapter.FillBy(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub btnConsideredFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsideredFilter.Click
        Try
            Me.ApplicantsTableAdapter.FillBy(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
 
    Private Sub FillBy1ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillBy1ToolStripButton.Click
        Try
            Me.ApplicantsTableAdapter.FillBy1(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
 
    Private Sub btnSYEPFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSYEPFilter.Click
        Try
            Me.ApplicantsTableAdapter.FillBy1(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
 
    Private Sub FillBy2ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillBy2ToolStripButton.Click
        Try
            Me.ApplicantsTableAdapter.FillBy2(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
    End Sub
 
    Private Sub txtAllFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAllFilter.Click
        Try
            Me.ApplicantsTableAdapter.FillBy2(Me.SYEP2007DataSet.Applicants)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class
ASKER CERTIFIED SOLUTION
Vadim Rapp

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros