none
Two or more function in 1 "Load Form", is severely hindering functionality of the application RRS feed

  • Question

  • I included several functions in "Load" startup of the form, it is taking very long to load

    I tried inserting the code "Sleep(1000)", but it is not effective in avoiding slow down of loading the form.

    If I insert a message box between the two functions, then it runs very quickly.

    HOW can I insert a separator (not using a message box) between two functions to AVOID slowing down application functionality. 

    the Function are Loading the Feilds on Form from an SQL Conection, or Making Some Calacalation

    Tuesday, August 20, 2019 2:42 PM

Answers

  • With that much code/logic altering tables along with goto statements the true path to learn what the bottleneck is to make use of Visual Studio's Analyzing tools and diagnostics while running the app in debug mode.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by MosheS Singer Tuesday, August 20, 2019 9:54 PM
    Tuesday, August 20, 2019 8:34 PM
    Moderator

All replies

  • Hi

    Show your code ...................


    Regards Les, Livingston, Scotland

    Tuesday, August 20, 2019 3:03 PM
  • I have aproximately 10 projects in my application, and this problem is prevalent in all my projects. For example, if I run a code to apply a payment to a specific charge, it will compete the task in a second. Or for example, if I run code to select all the payments that were not yet applied to a charge, it will also run in a second.

    However, if I combine both codes to do the two above mentioned functions, it will get stuck and remain frozen for about ten minutes!

    I need advice which separator to insert between the two codes (not a message box) to keep it running smoothly.

    Tuesday, August 20, 2019 3:12 PM
  • Hello,

    If possible make these methods asynchronous task.  Asynchronous task can keep an app responsive, provide cancellation and control over multiple or single task. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, August 20, 2019 3:19 PM
    Moderator
  • i tested to do 

    asynchronous task

    it dosnt help

    Thanks

    Tuesday, August 20, 2019 6:41 PM
  • i tested to do 

    asynchronous task

    it dosnt help

    Thanks

    Without seeing some code this will be hard to help with.

    Are you implying that you have one of the projects start the others? and that each of them has something in the Load event handler?


    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Tuesday, August 20, 2019 6:51 PM
  • OK 

    here is a sample code takes sometimes 5 minut

    it is to check if the custumer database is updated with all fields

      
     Private Sub BdfldsF()
             Try
    
            Dim lctnStr As String = ""
            Dim ADLtmp As New OleDbDataAdapter
            Dim DStmp As New DataSet
            Dim ADsLtmp As New SqlClient.SqlDataAdapter
            Dim AdlKsExuP As SqlCommand
            Dim AdlKTExuP As OleDbCommand
            If CkifClmExiztMF("Select * FROM DHCR", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE DHCR ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE DHCR ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM PicturesT", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE PicturesT ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE PicturesT ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM CntctTbl", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE CntctTbl ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE CntctTbl ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM MasegLn", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE MasegLn ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE MasegLn ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Foreigen", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE Foreigen ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE Foreigen ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Zips", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE Zips ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE Zips ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Masages", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE Masages ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE Masages ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM AssortedMailings", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE AssortedMailings ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE AssortedMailings ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Loctn", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE Loctn ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE Loctn ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitTenant", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE UnitTenant ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE UnitTenant ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitCWC", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE UnitCWC ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE UnitCWC ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitRent", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE UnitRent ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE UnitRent ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitCwcBl", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE UnitCwcBl ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE UnitCwcBl ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitPrcnt", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE UnitPrcnt ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE UnitPrcnt ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ReminderT", "ToLoad") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE ReminderT ADD ToLoad Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE ReminderT ADD ToLoad bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("SELECT * FROM TblSttmnt30", "T30Id") = False Then
                If My.MySettings.Default.aplctn = 1 Then 'access
                    lctnStr = "ALTER Table TblSttmnt30 ADD T30Id PRIMARY KEY AUTOINCREMENT"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER Table TblSttmnt30 ADD T30Id INT IDENTITY(1,1)"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("SELECT * FROM AcntNmPrg", "Usr") = False Then
                lctnStr = "ALTER Table AcntNmPrg ADD Usr nvarchar(255)"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
                If My.MySettings.Default.aplctn = 1 Then 'access  
                    lctnStr = "UPDATE AcntNmPrg SET AcntNmPrg.Usr = 'tov'"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "Update AcntNmPrg SET AcntNmPrg.Usr='tov' From AcntNmPrg"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM SetLtr", "CDt_0Y") = False Then
                lctnStr = "ALTER Table SetLtr ADD CDt_0Y BIT"
                If My.MySettings.Default.aplctn = 1 Then 'access  
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM SetLtr", "CDt_0D") = False Then
                lctnStr = "ALTER Table SetLtr ADD CDt_0D datetime"
                If My.MySettings.Default.aplctn = 1 Then 'access  
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM NdvimUnstal", "SowUnt") = False Then
                lctnStr = "ALTER Table NdvimUnstal ADD SowUnt bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM NdvimUnstal", "AutoAply") = False Then
                lctnStr = "ALTER TABLE NdvimUnstal ADD AutoAply bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ListNames", "Photo") = False Then
                lctnStr = "ALTER TABLE ListNames ADD Photo image"
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ListNames", "Pridd") = False Then
                If My.MySettings.Default.aplctn = 1 Then   'access  
                    lctnStr = "ALTER TABLE ListNames ADD Pridd Number"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE ListNames ADD Pridd bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ATaskList", "Photo") = False Then
                lctnStr = "ALTER TABLE ATaskList ADD Photo image"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ATaskTtl", "Photo") = False Then
                lctnStr = "ALTER TABLE ATaskTtl ADD Photo image"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM IncomeT", "Organize") = False Then
                lctnStr = "ALTER TABLE IncomeT ADD Organize nvarchar(255)"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitTenant", "Newest") = False Then
                lctnStr = "ALTER TABLE UnitTenant ADD Newest bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Property", "Sprinkler") = False Then
                lctnStr = "ALTER TABLE Property ADD Sprinkler bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Property", "SprnklrDT") = False Then
                lctnStr = "ALTER TABLE Property ADD SprnklrDT datetime"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM IncomeT", "PictureT") = False Then
                If My.MySettings.Default.aplctn = 1 Then 'If access Then
                    lctnStr = "ALTER TABLE IncomeT ADD PictureT nvarchar(255)"
                ElseIf My.MySettings.Default.aplctn = 2 Then  'if sql then
                    lctnStr = "ALTER TABLE IncomeT ADD PictureT nvarchar(1255)"
                End If
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Unit", "Sprinkler") = False Then
                lctnStr = "ALTER TABLE Unit ADD Sprinkler bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM Unit", "SprnklrDT") = False Then
                lctnStr = "ALTER TABLE Unit ADD SprnklrDT datetime"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitRent", "Sprinkler") = False Then
                lctnStr = "ALTER TABLE UnitRent ADD Sprinkler bit"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM UnitRent", "SprnklrDT") = False Then
                lctnStr = "ALTER TABLE UnitRent ADD SprnklrDT datetime"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ServiceStngs", "typN2") = False Then
                lctnStr = "ALTER TABLE ServiceStngs ADD typN2 nvarchar(255)"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM rentals", "UnitID") = False Then
                If My.MySettings.Default.aplctn = 1 Then 'access
                    lctnStr = "ALTER TABLE rentals ADD UnitID numeric(18, 0)"
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    lctnStr = "ALTER TABLE rentals ADD UnitID bigint"
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("Select * FROM ListNames", "CompID") = False Then
                lctnStr = "ALTER TABLE ListNames ADD CompID numeric(18, 0)"
                If My.MySettings.Default.aplctn = 1 Then   'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            Dim CSql As String
            If My.MySettings.Default.aplctn = 1 Then      'If access Then
                If CkifClmExiztMF("Select * FROM ChartOfAccounts", "Grouping") = False Then
                    lctnStr = "ALTER TABLE ChartOfAccounts ADD Grouping nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("Select * FROM ChartOfAccounts", "SubGrouping") = False Then
                    lctnStr = "ALTER TABLE ChartOfAccounts ADD SubGrouping nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("Select * FROM ChartOfAccounts", "CategoryTypeToDisplay") = False Then
                    lctnStr = "ALTER TABLE ChartOfAccounts ADD CategoryTypeToDisplay nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                    Windows.Forms.Application.DoEvents()
                    Windows.Forms.Application.DoEvents()
                    Windows.Forms.Application.DoEvents()
                    lctnStr = "UPDATE ChartOfAccounts Set ChartOfAccounts.Grouping = [Group], ChartOfAccounts.SubGrouping = [Group2], ChartOfAccounts.CategoryTypeToDisplay = [Category type To display]"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
    GoStPwtF:
                End If
                If CkifClmExiztMF("Select * FROM ServiceStngs", "ctgry2") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD ctgry2 nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("Select * FROM ServiceStngs", "ctgry3") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD ctgry3 nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("Select * FROM ServiceStngs", "dscrib2") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD dscrib2 nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("Select * FROM ServiceStngs", "dscrib3") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD dscrib3 nvarchar(255)"
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                End If
            ElseIf My.MySettings.Default.aplctn = 2 Then  'if sql then
                If CkifClmExiztMF("Select * FROM ChartOfAccounts", "Grouping") = False Then
                    CSql = "SP_RENAME 'ChartOfAccounts.[Group]', 'Grouping', 'COLUMN'"
                    Using SqlConct As New SqlConnection(SQLKT)
                        SqlConct.Open()
                        AdlKsExuP = New SqlCommand(CSql, SqlConct)
                        AdlKsExuP.ExecuteNonQuery()
                        CSql = "SP_RENAME 'ChartOfAccounts.Group2', 'SubGrouping', 'COLUMN'"
                        AdlKsExuP.CommandText = CSql
                        AdlKsExuP.ExecuteNonQuery()
                        CSql = "SP_RENAME 'ChartOfAccounts.[Category type to display]', 'CategoryTypeToDisplay', 'COLUMN'"
                        AdlKsExuP.CommandText = CSql
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            Dim ADLstckQ As New OleDbDataAdapter
            Dim DSstckQ As New DataSet
            Dim ADsLstckQ As New SqlClient.SqlDataAdapter
            If CkifClmExiztMF("SELECT * FROM catgories", "Description") = False Then
                lctnStr = "ALTER TABLE catgories ADD Description nvarchar(255)"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
                Windows.Forms.Application.DoEvents()
                Windows.Forms.Application.DoEvents()
                lctnStr = "UPDATE catgories SET catgories.Description = [DESC]"
                If My.MySettings.Default.aplctn = 1 Then 'access
                    Using OLExConct As New OleDbConnection(AccessKT)
                        OLExConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLExConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf My.MySettings.Default.aplctn = 2 Then 'or sql
                    Using SqlxConct As New SqlConnection(SQLKT)
                        SqlxConct.Open()
                        AdlKsExuP = New SqlCommand(lctnStr, SqlxConct)
                        AdlKsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
    GoctDdF:
            If CkifClmExiztMF("SELECT * FROM Foreigen", "ForeigenID") = False Then
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'If access Then
                    lctnStr = "CREATE TABLE Foreigen (ForeigenID numeric PRIMARY KEY, ID numeric  NULL, Name VARCHAR(255)  NULL)"
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then  'if sql then
                    lctnStr = "CREATE TABLE Foreigen (ForeigenID numeric(10, 0) PRIMARY KEY, ID numeric(10, 0)  NULL, Name VARCHAR(255)  NULL) "
                End If
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
    Mossafd:
            If CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'if sql then
                If CkifClmExiztMF("SELECT * FROM ServiceStngs", "ctgry2") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD ctgry2 nvarchar(255)"
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("SELECT * FROM ServiceStngs", "ctgry3") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD ctgry3 nvarchar(255)"
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("SELECT * FROM ServiceStngs", "dscrib2") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD dscrib2 nvarchar(255)"
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                If CkifClmExiztMF("SELECT * FROM ServiceStngs", "dscrib3") = False Then
                    lctnStr = "ALTER TABLE ServiceStngs ADD dscrib3 nvarchar(255)"
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                lctnStr = "ALTER TABLE ListNames ALTER COLUMN [TitleN] nvarchar(4000)"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                lctnStr = "ALTER TABLE ListNames ALTER COLUMN [FirstN] nvarchar(4000)"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
                lctnStr = "ALTER TABLE ListNames ALTER COLUMN [LastN] nvarchar(4000)"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("SELECT * FROM NdvimUnstal", "MoreTnnts") = False Then
                lctnStr = "ALTER TABLE NdvimUnstal ADD MoreTnnts bit"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
    GonxtMot:
            If CkifClmExiztMF("SELECT * FROM IncomeT", "Payee") = False Then
                lctnStr = "ALTER TABLE IncomeT ADD Payee nvarchar(255)"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
    GonextF:
            If CkifClmExiztMF("SELECT * FROM TblSttmnt", "Payee") = False Then
                lctnStr = "ALTER TABLE TblSttmnt ADD Payee nvarchar(255)"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
            If CkifClmExiztMF("SELECT * FROM IncomeT", "CloseT") = False Then
                lctnStr = "ALTER TABLE IncomeT ADD CloseT bit"
                If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                    Using OLEmConct As New OleDbConnection(AccessKT)
                        OLEmConct.Open()
                        AdlKTExuP = New OleDbCommand(lctnStr, OLEmConct)
                        AdlKTExuP.ExecuteNonQuery()
                    End Using
                ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                    Using SqlmConct As New SqlConnection(SQLKT)
                        SqlmConct.Open()
                        Dim AdlKTsExuP As New SqlCommand(lctnStr, SqlmConct)
                        AdlKTsExuP.ExecuteNonQuery()
                    End Using
                End If
            End If
    GoClstF:
    
        End Sub
    
    Public Function CkifClmExiztMF(tblNm As String, ClmNm As String) As Boolean
            Dim ADLtmp As New OleDbDataAdapter
            Dim DStmp As New DataSet
            Dim ADsLtmp As New SqlClient.SqlDataAdapter
            Dim ADLWstngT As New OleDbDataAdapter
            Dim DSWstngT As New DataSet
            Dim ADsLWstngT As New SqlClient.SqlDataAdapter
            If CInt(My.MySettings.Default.aplctn.ToString) = 1 Then 'access
                Using OLEAConct As New OleDbConnection(AccessKT)
                    OLEAConct.Open()
                    ADLWstngT.SelectCommand = New OleDbCommand(tblNm, OLEAConct)
                    ADLWstngT.Fill(DSWstngT)
                End Using
            ElseIf CInt(My.MySettings.Default.aplctn.ToString) = 2 Then 'or sql
                Using SqlAConct As New SqlConnection(SQLKT)
                    SqlAConct.Open()
                    ADsLWstngT.SelectCommand = New SqlCommand(tblNm, SqlAConct)
                    ADsLWstngT.Fill(DSWstngT)
                End Using
            End If
            If DSWstngT.Tables(0).Columns.Contains(ClmNm) Then
                CkifClmExiztMF = True
            Else
                CkifClmExiztMF = False
            End If
        End Function

    Tuesday, August 20, 2019 7:43 PM
  • Hi

    My thought for the day: be careful what you ask for .......


    Regards Les, Livingston, Scotland

    Tuesday, August 20, 2019 7:59 PM
  • With that much code/logic altering tables along with goto statements the true path to learn what the bottleneck is to make use of Visual Studio's Analyzing tools and diagnostics while running the app in debug mode.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by MosheS Singer Tuesday, August 20, 2019 9:54 PM
    Tuesday, August 20, 2019 8:34 PM
    Moderator