|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
Vista 3 Build 84 If you have customer table with 50 rows. ID_Customer 1-50 and use this find with a VistaDBDataTable: Dim tbl As New VistaDBDataTable(DB, TableName, False, False, "PrimaryKey", 100, True) tbl.Find("ID_Customer:'5' ", "PrimaryKey", False, False) I assumed that the cursor would move to the 5th record. It does. But when you set the table to the datasource of a BindingSource and then the BindingSource to a DatagridView you will only see the records 5-50. Records 1-4 ARE NOT THERE!. If you do a ClearScope the records comeback but the cursor goes to the first record. Here is what I am trying to accomplish: I have a current record key. Position the cursor to the key position. Load the records in to the DataGridView. Highlight the row in the DGV to the current record key. The user moves the DGV selected row to another record and then exits. I want to know what new record key the user moved to. This seems impossible with VistaDBDataTable but should be elementary! I should be able to get the current row from BindingSource.Current but it is not the current row! File Attachment(s):  CFDBDemo.vdb3 (114kb) downloaded 0 time(s).
|
|
|
|
Rank: Team VistaDB
Groups: Member, Team VistaDB
Joined: 8/13/2006 Posts: 606 Points: 2,577 Location: Edinburgh, Scotland
|
What happens if you set the table to the datasource of a BindingSource and then the BindingSource to a DatagridView first, then do the find?
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
Same thing. The DGV displays the data starting at the Found row. There is no going back.
|
|
|
|
Rank: Team VistaDB
Groups: Member, Team VistaDB
Joined: 8/13/2006 Posts: 606 Points: 2,577 Location: Edinburgh, Scotland
|
Before doing the find are the missing rows visible?
|
|
|
|
Rank: VistaDB Staff
Groups: Administration, VistaDB Staff
Joined: 8/13/2006 Posts: 3,633 Points: 5,124 Location: Mount Dora, Florida
|
Are you meaning to use DDA for this application? You are using some DDA concepts above and they are different than SQL concepts. I would highly recommend you to use the ADO.NET concepts and follow SQL rather than DDA. This is especially true if you are just starting out as the DDA concepts are a LOT more confusing to people who read things about .Net. Using the ADO.Net interface also means there is a LOT more help on how to do things. Without a sample that can compile I can't tell what is happening above. It could be that your indexes are wrong, your PKs are wrong, your datagrid is bound incorrectly, etc. There are just too many ways things can go wrong to guess from that code snippet. Jason Short
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
I an NOT new to VistaDB. I have SPECIFIC reasons to use DDA. Here is the code. The database is here: Vista Database Code: Dim BS As New BindingSource ' Dim Row As IVistaDBRow Dim DDA As IVistaDBDDA = VistaDBEngine.Connections.OpenDDA Dim DatabaseName As String = Directory.GetCurrentDirectory + "\CFDBDemo.vdb3" Dim DB As IVistaDBDatabase = DDA.OpenDatabase(DatabaseName, VistaDBDatabaseOpenMode.NonexclusiveReadWrite, Nothing) Dim ActiveIndex As String = "PrivateKey" If ActiveIndex.Length = 0 Then ActiveIndex = "PrimaryKey"
ActiveIndex = "PrimaryKey"
Dim tbl As New VistaDBDataTable(DB, "Customer", False, False, ActiveIndex, 100, True)
With tbl 'If mCurrentFilter.Length Then .SetFilter(mdbTable.GetFilter(True), True) 'Set active index
End With BS.DataSource = tbl
tbl.Find("ID_Customer:'A'", ActiveIndex, False, False) DGV.DataSource = BS
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
Sorry. There were a couple of typos in the code. Use this: Code: Dim BS As New BindingSource Dim DDA As IVistaDBDDA = VistaDBEngine.Connections.OpenDDA Dim DatabaseName As String = Directory.GetCurrentDirectory + "\CFDBDemo.vdb3" Dim DB As IVistaDBDatabase = DDA.OpenDatabase(DatabaseName, VistaDBDatabaseOpenMode.NonexclusiveReadWrite, Nothing) Dim ActiveIndex As String = "PrimaryKey"
Dim tbl As New VistaDBDataTable(DB, "Customer", False, False, ActiveIndex, 100, True)
With tbl 'If mCurrentFilter.Length Then .SetFilter(mdbTable.GetFilter(True), True) 'Set active index
End With BS.DataSource = tbl
tbl.Find("ID_Customer:'A'", ActiveIndex, False, False) DGV.DataSource = BS
|
|
|
|
Rank: VistaDB Staff
Groups: Administration, VistaDB Staff
Joined: 7/5/2008 Posts: 252 Points: 1,776 Location: Mount Dora, Florida
|
Are you trying to display all 50 records, but highlight or select a particular record in the control? If so, you do not want to use scope or filter as they are data level limits and will limit the data the control see's. even though Find will move the current row to the row you want, it will not give you the results you want. Most data sources are built on the forward cursor concept. So if you advance to row 5 and then bind the data source it will treat row 5 as the first row. What you need to do is set the primary key of your data source and then select against that primary key. I have never worked with databinding in VB so I am not sure what steps to give you, but in the c# world, you would tell the control to make a particular primary key active or selected and it would handle selecting the correct row. This, however, is outside of the actual underlying datasource, as it is the consumer controlling the selection not the provider. Michael Swain VistaDB Software
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
OK. I can move the selection highlight of the DGV by setting the BS.Position. I can get the user selection position from BS.Position. How do I retrieve the record data from the VistsDBDataTAble? BS.Current does not contain the VistaDBRow. What object does BS.Current represent? I would think it would be a VistaDBRow.
|
|
|
|
Rank: Team VistaDB
Groups: Member, Team VistaDB
Joined: 8/13/2006 Posts: 606 Points: 2,577 Location: Edinburgh, Scotland
|
I get a page not found when I try to download the file!
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
Right click on the link and choose Save As.
Al
|
|
|
|
Rank: Team VistaDB
Groups: Member, Team VistaDB
Joined: 8/13/2006 Posts: 606 Points: 2,577 Location: Edinburgh, Scotland
|
Nope, no luck there: 
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/27/2009 Posts: 7 Points: 21 Location: FL
|
Strange. I can DL it here. I have used the Attach button to attach it, however I don't really know how you retrieve it from this Forum. Give ma an email and I can send it to you. I zipped it try this link http://www.trans-micro.com/download/cfdbdemo.zip
Al
|
|
|
|
Rank: Team VistaDB
Groups: Member, Team VistaDB
Joined: 8/13/2006 Posts: 606 Points: 2,577 Location: Edinburgh, Scotland
|
|
|
|
|
Rank: VistaDB Staff
Groups: Administration, VistaDB Staff
Joined: 8/13/2006 Posts: 3,633 Points: 5,124 Location: Mount Dora, Florida
|
BindingSource.Current can be anything. It is an object to Visual Studio, so you will have to forward cast it if you want anything out of it. If you want to navigate through a BindingSource you should be using a BindingNavigator in order to navigate through the records, and then accessing the DataGridView.Rows to look at the individual rows. Once you get anything in a DataGrid you should not normally go back to the DDA object to modify it. The DataGridView.SelectedCells will tell you what is currently selected, etc. You normally treat any databound class as hands off. Once you assign it to databind you leave it alone and only mess with it through the object it is bound to directly. Otherwise you can end up with 2 edits (one in the underlying store and one in the bound object). In your code snippet above you also would have problems of those variables be local in scope and falling out of context to be GC cleaned at some point. Please submit a project that we can actually run if you want people to help further. For an example of using the VistaDBDataTable with binding and a grid you can look at the DataForm.cs in the DBA Sample Tool. It shows navigating with a BindingNavigator, clearing, getting datarows, etc. Jason Short
|
|
|
|
Rank: Member
Groups: Member
Joined: 5/2/2009 Posts: 69 Points: 207 Location: Oakbrook Terrace IL
|
js_vistadb wrote:BindingSource.Current can be anything. It is an object to Visual Studio, so you will have to forward cast it if you want anything out of it.
If you want to navigate through a BindingSource you should be using a BindingNavigator in order to navigate through the records, and then accessing the DataGridView.Rows to look at the individual rows. Once you get anything in a DataGrid you should not normally go back to the DDA object to modify it. The DataGridView.SelectedCells will tell you what is currently selected, etc.
You normally treat any databound class as hands off. Once you assign it to databind you leave it alone and only mess with it through the object it is bound to directly. Otherwise you can end up with 2 edits (one in the underlying store and one in the bound object).
In your code snippet above you also would have problems of those variables be local in scope and falling out of context to be GC cleaned at some point.
Please submit a project that we can actually run if you want people to help further.
For an example of using the VistaDBDataTable with binding and a grid you can look at the DataForm.cs in the DBA Sample Tool. It shows navigating with a BindingNavigator, clearing, getting datarows, etc.
What is said above makes sense. I need to use a VistaDBDataTable in order to get reasonable speed from a DataGridView. I tried using BindingSource.Fund to find a key value to position the dataset within the grid based on the column name and a value, but that comes back with a Not Implemented Exception. How is this to be done if the binding source cannot interface completely with the VistaDBDataTable? Or, am I missing something?
|
|
|
|
Guest
|