0

I created a winform desktop application vb.net with a DBF database and a DBF database in use in a dos application. So is there a solution to re-index the winform without having to re-load the form or is there another solution so that I can create a primary key. Because DBF Databases do not have a primary key. If the DBF database is updated from the dos application while the winform desktop application is running, how can I overcome the primary key index?. In Winform I updated the database from DataGrivdView with "adapter. Update(dt)" which must have a primary key.

Thanks

  Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            DropindexRPD()
            AddindexRPD()
            LoadData()
        End Sub
        Private Sub DropindexRPD()
            Try
                Using cn As New OleDbConnection(connectionString)
                    Using cmd As New OleDbCommand("DROP INDEX idxMyTable ON RPD;", cn)
                        cn.Open()
                        cmd.ExecuteNonQuery()
                    End Using
                End Using
            Catch
            End Try
        End Sub
        Private Sub AddindexRPD()
            Try
                Using cn As New OleDbConnection(connectionString)
                    Using cmd As New OleDbCommand("ALTER TABLE RPD ADD CONSTRAINT idxMyTable PRIMARY KEY (PNM,NOD)", cn)
                        cn.Open()
                        cmd.ExecuteNonQuery()
                    End Using
                End Using
            Catch
            End Try
        End Sub
roy
  • 693
  • 2
  • 11

0 Answers0