Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I have the following code that pastes into a tableadapter and I am looking for a way to improve the performance. Currently it takes a min to paste a 100 records.

VB
Sub ParseSpecList()
        Dim myTable As New cbot_dbDataSetTableAdapters.SpecsTableAdapter
        Dim strSpec As String
        Dim myText As String()
        myText = Clipboard.GetText.Split(Environment.NewLine)

        For Each item As String In myText
            strSpec = item.Trim
            If strSpec <> "" Then
                Try
                    myTable.InsertQuerySpec(strSpec, False)
                Catch ex As System.Data.SqlServerCe.SqlCeException
                    'skip add
                Catch ex As Exception
                    ' Show the exception's message.
                    MessageBox.Show(ex.Message)
                    Debug.Print(ex.Message)
                    ' Show the stack trace, which is a list of methods
                    ' that are currently executing.
                    MessageBox.Show("Stack Trace: " & vbCrLf & ex.StackTrace)
                End Try
            End If
        Next item

    End Sub
Posted
Comments
Richard Deeming 9-Dec-14 12:30pm    
You'd need to profile your code to find the bottleneck. It's most likely within the InsertQuerySpec method, which you haven't shown.
ZurdoDev 9-Dec-14 14:34pm    
Agreed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900