Adding table values to a treeview - database

I am using Vb 2008 express edition and am very new to treeviews. i have basic knowledge of how to connect to a database. the database i am working with is a microsoft access database and has a large amount of tables with various information. two of these tables i need to put into a treeview. one has 2 columns called date and date id, the date will be the main nodes on the treeview. the other table has 8 colums, among them are the corresponding date id's from the first table, the purchase order id and the purchase order number. the child nodes will be the purchase order number.
Now i know there are a bunch of tutorials out there on treeview population through microsoft access databases but i have found none specifically with what i need, they are all just about dumping ALL the data from the database into the table. i just want specific contents of two tables. if someone could help me out with this i would be very grateful. i can give more information if needed on what i am working with or anything else.!
This is an example of what it needs to look like. i am upgrading this program from vb6 to vb.net which is why i already have the program.

What you will have to do is loop through the first table (using sql and a datareader, for example) and then create the initial (parent) nodes. (Note that the below is a general idea, you will have to figure out the loop and datareader parts).
looping structure
TreeView1.Nodes.Add(nodeName, nodeName)
next record
Then, loop through the second table, adding the record to the correct node...
looping structure
TreeView1.Nodes(parentNodeName).Nodes.Add(nodeName, nodeName)
next record

Related

Creating "View" to connect two Databases

I have two Databases, one which looks at Financial Year 2018- 2019 and another which will be looking at Financial year 2019-2020.
Now these are Sage Databases so they have a lot of Tables within each of them, the setup of each Database is exactly the same.
Now I had a report which looked at the current financial year no problem, but I didn't realise that they had it set up as the previous financial year would be stored in a separate Database.
I've said "View" within my title, but that's not really what I need as I need whole tables.
So my question is this, is there a construct within SQL that will allow me to create a new datasource of some kind which contains the 12 tables I actually need to populate my report and the data inside these tables be a union of the 12 tables from 18-19 and the 12 tables of 19-20.
I hope that make a least a little sense.
(I would just try and make use of a view, but there's multiple datasets within the report which make use of the joins in slightly different ways)

Access Database - Display different data

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

Updating dimension tables using SQL Server (BIDs or Data Tools)

I'm quite confused as to how I'm supposed to be adding dimension members to my data warehouse. Let's say that TOWN_NAME is a dimension table that links town_Id to a town_name. So, now, I have 1000 customer names, and they are from 9 towns. Suddenly, in my next ETL process, a customer ends up being added whose town is not amongst that 9 towns i have in my dimension. So I need to add a member to my dimension table. Which step/process in BIDS or DATA TOOLS (BIDS 2012) would have I to use? How should this be one? I'm quite lost as to what could be done.
The usual pattern - regardless of what tools you're using to populate your data warehouse - is to populate your Dimension before you populate your Fact, precisely to avoid this problem.
The usual way to do things is to have a package which pulls out your Dimension data from your source system(s), and then load any new rows into your Dimension table. Then, when your Fact table load happens later in the process you look-up the ID column from the Dimension using the town name. Your Fact data should then be loaded into the Fact table with the ID for the relevant town as one of its column values.
Specifically, in SSIS, you can manage this by creating a package which does your Dimension table load, and another package in the same project which does your Fact table load. Then you can control the order these happen in a couple of different ways:
You can create a third package which uses two Execute Package tasks to call the Dimension package first, and then the Fact package.
You could create a SQL Server Agent Job which first calls the Dimension package, then calls the Fact package.
If you want to be able to run everything from within Visual Studio in order in one go, then go with the first option.

Database Table Design: Expanding a data table while maintaining backwards compatibility

The project I'm working on tracks data on a year by year basis. The user will log into the system and specify the year it wants to access the data of. For example, the user could specify the year 2004, and the .jsp pages will display 2004 data.
My problem is that from 2013 onward, the data for one .jsp page will be different, and the current database table schema needs to be modified, but backwards compatibility for the 2012 and before years needs to be maintained.
Currently (2012 and before), the relevant database table displays two columns, "continuing students" & "new starts" that is displayed by a single .jsp. For 2013 and onward, 4 columns need to be displayed. The original two columns are being split into two subcategories each, undergrad and graduate. So I can't simply add those new columns to the existing table because that would violate third normal form.
What do you think the best way to manage this situation? How do I display the new data while still maintaining backwards compatibility to display the data for older years?
Some options:
Introduce the fields and allow for nulls for older data. I think you rejected this idea.
Create new table structures to store the new data going forward. It's an least an option if you don't want (1). You could easily create a view that queries from both tables and presents a unified set of data. You could also handle this in the UI and call two separate stored procedures depending on the year queried.
Create a new table with the new attributes and then optionally join back to your original table. This keeps the old table the same and the new table is just an extension of the old data. You would write a stored procedure potentially to take in the year and then return the appropriate data.
One of the things to really consider is that the old data is now inactive. If you aren't writing to it anymore, it's just historical data that can be "archived" mentally. In that case I think it's ok to freeze the schema and the data and let it live by itself.
Also consider if your customers are likely to change the schema yet again. If so, then maybe (1) is the best.

Missing data in first record in MS Access (front end) and using SQL Server (back end)

I have a database that I just converted the back end to SQL Server using SSMA. I left the front end in MS Access. I only converted the tables and not the queries. It already had some data in it and that moved over just fine.
All was going well until just recently. On opening the database and loading the main form Event Interest it started having problems with the first record of the subform, called Names. The first field in the first record has data sometimes and not others. This is a text field. When data is in the field it puts in random numbers. I believe they may be related to SQL somehow. When there is no data/missing you can select the field and hit the backspace button and the data will appear minus the one character you just errased. I have no idea what is going on.
Any help you can supply I would greatly appreciate it. Thank you in advance.
I am new to SQL Server and I have used older versions of MS Access for a few years.
I am not certain what the problem might be, but these are some considerations that come to mind:
try deleting and recreating your linked tables. Perhaps an update to the table structure (or view, if you're linked to a view) has invalidated some of the metadata stored in the table link in your front end.
does your table have a primary key? If not, you really need one. There really is no such thing as a properly-designed data table in a relational database that is PK-less.
does your table have a timestamp? If not, add one, as this helps Access keep track of whether or not the data has changed on the server.
However, let me add that none of these issues manifest themselves exactly with the symptoms you've described, so they may not help.

Resources