I think it was working a few days ago but now it's not. The funny thing is if I have the mdb open and I run this, the values get replaced with "#Deleted" and when I close it and reopen they are gone. But, if I have it closed, nothing happens.
What could be the problem?
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.Filter = "mdb files(*.mdb)|*.mdb" OpenFileDialog1.ShowDialog() con.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & OpenFileDialog1.FileName con.Open() sql = "Select * From Files" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "Files") maxrows = ds.Tables("Files").Rows.Count ReDim filename(maxrows) ReDim setid(maxrows) ReDim filesize(maxrows) For i = 0 To maxrows - 1 setid(i) = ds.Tables("Files").Rows(i).Item(0) filename(i) = ds.Tables("Files").Rows(i).Item(2) filesize(i) = ds.Tables("Files").Rows(i).Item(4) Next Dim filename2 As String() = DirectCast(filename.Clone(), String()) Array.Sort(filename, setid) Array.Sort(filename2, filesize) Dim cb As New OleDb.OleDbCommandBuilder(da) For i = 0 To maxrows - 2 If filename(i) = filename(i + 1) And setid(i) = setid(i + 1) Then RichTextBox1.Text = RichTextBox1.Text & vbCrLf & setid(i) RichTextBox1.Text = RichTextBox1.Text & vbCrLf & setid(i + 1) RichTextBox2.Text = RichTextBox2.Text & vbCrLf & filename(i) RichTextBox2.Text = RichTextBox2.Text & vbCrLf & filename(i + 1) RichTextBox3.Text = RichTextBox3.Text & vbCrLf & filesize(i) RichTextBox3.Text = RichTextBox3.Text & vbCrLf & filesize(i + 1) If filesize(i) > filesize(i + 1) Then ds.Tables("Files").Rows(i).Delete() da.Update(ds, "Files") ElseIf filesize(i) < filesize(i + 1) Then ds.Tables("Files").Rows(i + 1).Delete() da.Update(ds, "Files") Else MsgBox(filename(i) & " has a dupe filesize") End If End If Next con.Close() End Sub




Reply With Quote