-
Mar 27th, 2016, 01:05 PM
#1
Thread Starter
Junior Member
Reload DataGridView
Ok this is driving me crazy, i am loading a datagridview sorted by date as follows.....
Public Sub LoadDatabaseDetails()
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
theDatabase = "\FirstDirect.mdb"
myDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
fullDatabasPath = myDocumentsFolder & theDatabase
dbSource = "Data Source = " & fullDatabasPath
con.ConnectionString = dbProvider & dbSource
con.Open()
da = New OleDb.OleDbDataAdapter("SELECT * FROM tblContacts ORDER BY newDate DESC", con)
da.Fill(ds, "BankStatement")
tables = ds.Tables
Dim view As New DataView(tables(0))
frmMaster.DataGridFD.DataSource = view
con.Close()
End Sub
I am adding new data without any issues but it always add's it to the bottom instead of Date order, i add using the following...
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("BankStatement").NewRow()
dsNewRow.Item("newDate") = txtDate.Text
dsNewRow.Item("Description") = txtDescription.Text
dsNewRow.Item("AmountIn") = txtAmountIn.Text
dsNewRow.Item("AmountOut") = txtAmountOut.Text
ds.Tables("BankStatement").Rows.Add(dsNewRow)
da.Update(ds, "BankStatement")
MessageBox.Show("New Record added to the Database")
da.Fill(ds)
DataGridFD.ResetBindings()
End If
End Sub
It's taken me ages to figure out
da.Fill(ds)
DataGridFD.ResetBindings()
Is there a better was of reloading the Data ????
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|