On a VB.NET 2008 form I have a DataGridView, BindingSource and TableAdapter.
The BindingSource DataSource is a dataset.
In the dataset I have a Fill command that joins three tables and this is displayed without a problem in the DataGridView.
However, I am unable to Update the dataGridView because it has multiple tables from a single TableAdapter?
Does anyone know a simple way I can update. The tables has over 200 columns and I only want to update the columns that are changed. If I use a single table I can edit data in the DataGridView and the database is updated ok.
Any help would be appreciated?
Thank you.
Unfortunately, the Windows.Forms BindingSource, does not support complex properties (which I assume you are after).
You would have to craft your own custom BindingSource (and it will likely be bespoke to you) to handle complex property values and assignments.
Related
The example above is where I'd like to have X axis coming from dataset_1, and Value coming from dataset_2.
In PowerBI and QlikSense, this is possible because 2 tables can be related via key fields without being joined.
But it seems in Quicksight, the visual is linked to a single dataset. When I change to a different dataset, the selection automatically goes out of the visual.
Am I missing some steps or is it just not possible in Quicksight?
In QuickSight, all visuals can only make use of a single dataset. However, if you have an author/admin account, you should be able to create a new dataset joining data coming from existing datasets see Creating dataset using existing datasets.
Alternatively you can create a new dataset and join the data coming from your datasource. See Joining Data
I am trying to "convert" a more complex Access database/user interface into a custom app using VB .NET. I am also a NOOB in .NET so please be gentle.
Here are the steps I'm trying to take to duplicate my results in .NET
1) Create a Data Source (dsServer) to my SQL Server that pulls all tables and all data. I created this Data Source in my project already using the UI.
2) Create a Data Table (dtResults) in my Data Source that pulls all the info I need from 3 tables:
[Person] - This is a single entry list.
[Primary Teacher] - This is linked through column (Primary) on the [Person] table. This will return single results.
[Test] - This is liked by [Person].ID. This table has multiple entries per [Person]
I have also created this data table in my project under the data source using the UI.
3) Populate 12 comboboxes on a form that will be used to "filter" my results onto a DataGridView. Each combobox needs to be a DISTINCT list of what is in dtResults. Each time a combobox changes, the results in the DataGridView need to be updated as well as all the other comboboxes. (narrowing the choices to only what is available)
4) Create a DataGridView on the same form that will display the filtered results.
I don't seem to have any issues with creating the datasource or the datatable. What I can't figure out is how to populate the comboboxes from the datatable or how to bring back my filtered results to the datagridview.
Any help on the best way to accomplish this would be great.
It sounds like you want a single results gridview to be filtered by the optional selection of 8 different combo boxes.
When you generate the query for the gridview, you'll need to selectively include the where clauses for each combo box with a value. That should be as simple as sql += " AND Combobox2Column = #Combobox2Value " for each combo box. Don't bother using the column like '%' pattern for combo boxes with no selection. That can have negative performance impacts and is not necessary if you build your query in VB before sending to the database.
(This is a scenario when using "WHERE 1=1" as the first predicate in the where clause comes in handy. It does have a little bit of overhead, but it standardizes all the rest of the predicates to always start with AND to prevent the additional overhead of determining if the specific combo box is the only combo box with a value selected. If your query requires any other filters not based on the combo box, this becomes unnecessary)
Another important factor is that changing any combo box will trigger the event to refresh the contents of the grid view. Put your combo box refresh logic in a dedicated method, separate from an event handler. Then you can easily call that method from the event handler for each combo box (or any other control/event).
Hope that helps.
Good morning everybody, this is the first time I write in this forum so, i'm sorry if I do some error!!!
I'm working on a project in Visual Studio where I'm connecting to an Access Database. The most important thing is that this Database is not mine and I can't modify it because it is updated daily by another automatic software.
I have to think that this database is "Read Only".
This database only has tables with primary key but there are no relation between tables.....it really looks like different Excel sheets!!!
I don't have problem to import the tables in a DatagridView of my Visual Studio project but in these tables the data are not easy to be understood for example:
there is a column named "Color" where the color are filled like number but there is not another Table who contain the color code. I know in my mind that color 1=Red, 2=Orange, 3=Brown etc.....
What I want to do?
I want that in my DataGridView won't be show the numbers but the color name so I need to modify my DataGrid source before display data.
How is did my project?
I have my DatagridView whose data source is a BindingSource that has a Dataset as DataSource. On my Load event I use the "Fill" method of my TableAdapter to display my tables data
Could someone suggest me how modify data before display them?
Thanks a lot
Giacomo
If all you are dealing with is a limited number of values in one or two fields, you could select the records using a query and obtain the color as follows:
SELECT Table1.ID, Table1.FldA, Table1.ClrFlag, IIf([clrflag]=1,"RED",IIf([clrflag]=2,"Orange",IIf([clrflag]=3,"Brown","Unknown")))
AS MyClr
FROM Table1
If there are many lookup's to do, I would create my own database with tables of code translations and join the two databases to produce my result. The following is an example of SQL pulling from two databases:
https://support.microsoft.com/en-us/help/113701/how-to-access-multiple-databases-in-an-sql-query-in-vb-3-0
For the life of me, I haven't been able to find this anywhere (other than solutions that exclude using the tableAdapter....
I have a simple setup. I have a datagridview. I have a tableadapter that is bound to the datagridview. This all works marvelously, but brings in the entire table. On the tableadapter itself, I have created a query called "nonServers" which returns the data I want.
So my question is, how can i bind the results of the tableadapter's QUERY to the datagridview, rather than the full results? When I try to add the query, it adds a button up top to trigger the query (as it's meant to do). But this is not what I want - i want the initial value to be the results of the query only.
any help appreciated, i reckon it's probably embarassingly simple
You're under some misconceptions. Firstly, your grid is not bound to a table adapter. The adapter is just a means to move data back and forth between the database and the application. The data is stored in the application a DataTable that is part of a DataSet. That's what your grid is bound to.
The default query for each table adapter is a SELECT * with no WHERE clause, so all columns and all rows. The table adapter has two methods - Fill and GetData - that execute that query. Fill will populate an existing DataTable, which will probably be part of a DataSet, while GetData creates and returns a new, standalone DataTable.
When you add a new query with a WHERE clause to filter, you are prompted to name the new methods that will execute that query. They are named FillBy and GetDataBy by default and you're supposed to append a meaningful suffix to that, e.g. if you were to filter by a ParentId column then you'd name the methods FillByParentId and GetDataByParentId. I'm not sure what exactly your query looks like but you might go with FillWithNonServers and GetDataWithNonSevers.
If you drag a table from the Data Sources window onto your form then that will add a bunch of controls and components by default and it will also generate some code, including a call to the Fill method of the appropriate table adapter to the Load event handler. In your case, you simply have to change that Fill call to a call to your new method and it will then invoke your custom query instead of the default.
This is prob basic question. When I create a datagrid I typically use a view and or tables from MS SQL. If I make an update in SQL for the view or alter the changes they do not comeover to my vb.net application. What I currently do is create a new project and copy and paste everything and add a new dataset. Is there a better way.
You can create a DataTable in your application and populate it with the table or view (or Select * from table) query results . This DataTable you can assign to your Datagrid view. You can create a timer (tick event) on your application and run the select query to update your applications datagrid every x seconds (or milliseconds). This may be a bit expensive and not pretty UI wise.
A better way would be to make your application sentient enough to recognise that the SQL server table has been updated. If the only way to update the SQL server is through your application , I suggest you can attach an event ( to the update_db or add_to_db code in your application ) and refresh your view whenever that event gets called.