Display MemberPath instead of Value in WPF DataGrid - sql

I have two SQL tables
In table 1 every row have value(string) in System Code column
In table 2 every row have value(int) in Device column which is ID of related Table 1 row.
Now i want to display Table 2 in WPF DataGrid and in Device Column value of System Code from Table 1. Now it's displaying ID of Table 1 row.
How can i do this?

Just create new class for the itmes, where you can store all needed properties. In your case it will be the projection of the join.
DataGrid's DisplayMemberPath relates only to the corresponding item. If data item which stands for representation of table's row allows naviagation to the property SystemCode of the Table1 then it is ok.

Related

How do I create a form to input new records into a table that contains only ID values from other tables?

I am new to databases, and I am working on a final project for a class. I have a database with tables related to each other as shown in the diagram here:
I want to create an unbound form that allows a user to add a new purchase to the purchase table by choosing their name, category, and store from data already in these tables, and then add purchase amount and date.
Since the purchases table does not contain the names of people, categories, and stores themselves, only the ID values from these tables' fields, I am struggling with how to create a form that will add the correct IDs into a new record in Purchases based on the names from other tables.
I am wondering if this requires VBA? I have tried playing around with the property sheet on forms, but I am struggling with which properties to address/what to do with them.
If anyone can explain at least a starting process to create this form.
Simply, use combo boxes that query Buyer, Category, and Store table data, hides the primary key ids, but shows the corresponding lookup value to the user. Users will select by the lookup value(s) but really are saving the id to Purchases table as new foreign key id.
As commented above, use a bounded form to map combo boxes to table id fields. Once you place a combo box, the default wizard will guide you on the steps but below are key property sheet attributes (which may be automatically set with wizard but can be manually adjusted later).
Data
Control Source: The column in table (i.e., PurchaseID, BuyerID, CatID, StoreID) to store the user-selected data of combo box (i.e., a form control).
Row source: A distinct SQL query of primary table id and all needed values for human searches. This can be a named table or saved query or an inline SELECT statement.
Row Source Type: If using SQL, Table/Query.
Bound Column: The position of primary table ID in the query resultset to be stored as foreign key Id. Usually this would be the first column.
Format
Column Count: The total number of columns from the recordsource including hidden, bound column.
Column Widths: To hide column from view, set its positional number within semicolon delimiters to zero. Preview form to decide how large to space out other columns. Do note: you can extend beyond the Width of combo box using List Width.
Column Heads: Optional and best if more than one column to guide users on the lookup value content (e.g., First Name, Last Name).
As example, for Category combo box on bounded Purchases table form, consider below property values:
Control Source: CatId
Row Source: SELECT CatId, CatName FROM Category
Row Source Type: Table/Query
Bound Column: 1
Column Count: 2
Column Width: 0";2.5"
Column Heads: No

Need update eligible data from one table to another

I have 2 tables. One is stage XYZ which contains raw data and the other is main table SKY in which most of the data is loaded as it is from stage.
The stage table is a truncate load table.
I want to check out records between these two which are not same??? In other words , I want to know which all attribute/column value is valid for a change from XYZ to SKY??
Be sure there are many columns in the SKY which is not available in XYZ.
XYZ has around 150 columns in total
And main table has 165( 15 are populated using some Informatica transformation from XYZ values, which i am not worried about)
In my opinion, The table XYZ should have a Auto Increment ID and the table Main will have the reference of that Auto Increment ID value. Once this structure is ready, informatica should always pick new records based on the value in Auto Increment ID column.
The select statement could be-
SELECT * FROM XYZ
WHERE Auto_ID > (SELECT MAX(Auto_ID) FROM Main)
Then you can apply further transformation on selected records for your purpose.

Changing Row Source of a Lookup depending on another field

I'm trying to define the row source of a lookup field by selecting the table name from a separate lookup box.
The catalog of products comprises of about 41 Product Groups, which are then further divided into Types, some of which have over 100 types.
I have a table of Product Groups (41 groups), and I then have a separate table of Types for each Product Group (41 tables). All Type table names are exactly as they appear on the Product Group table. I want to be able to select the Product Group from a Lookup Box, and then select the Type from the corresponding table in a separate lookup box.
The images below should help give an idea of what I'm looking to do.
Set up of my first lookup box:
Set up of my second lookup:
Is this possible, and if so can anyone lend a hand ?
Thanks.
Just to summarize, you will need a single table with your TypeID, GroupID, and any other "Type" related fields.
Your Group ComboBox should have the ID field as its first column (makes the filtering much easier), So your control source should be:
SELECT [ProductGroup]![GroupID], [ProductGroup]![ProductGroup]
FROM [ProductGroup]
ORDER BY [ProductGroup];
Then in the properties for Group ComboBox on the Format tab make your column width 0";x" to hide the ID field.
The control source for the Type ComboBox should be:
SELECT [NewTypeTable]![TypeID], [NewTypeTable]![TypeName]
FROM [NewTypeTable]
WHERE [NewTypeTable]![GroupID] Like [Forms]![frmWithComboBoxName]![CboPGroup]
ORDER BY [NewTypeTable]![TypeName];
And again, if you want to hide the ID field, make the first column width 0".
You should also requery the second combobox in the afterUpdate() event of CboPGroup which will filter the second combobox based on the new selection in CboPGroup. The code (VBA) for that would be:
Forms!frmWithComboBoxName!CboType.Requery

Oracle forms - values not populated for undisplayed items in a data block

I have a simple data block which is based from 1 single database table.
Example:
Table T has 5 columns A,B,C,D and E.
I use two text fields in Control block(non-database data block) in which the user keys in the values for A and B and click on search button.
Based on A,B in the text boxes, I query from the table T and get A,B,C,D,E and store them in my data block while displayed only C,D and E. [Note here the query retrieves A,B,C,D and E although only C,D and E get displayed]
Below are what I did:
1) Using the data block wizard, imported all columns(A,B,C,D,E) from the table to the data block.
2) Using the Layout wizard, imported all but two columns(A,B) to be displayed on the canvas.
When I insert a record into the data block and do a COMMIT_FORM, the two columns that was left undisplayed([2] above) has a value of NULL populated for it.
My question is why does this happen and what should I do to have A and B also populated in the table when I do an insert?
If the values of A and B should be the one of the two textfields then you should set the inital value of A and B to the corresponding items. If you query 3 records and go add a 4th the inital value will fire and the will get the value required.

Get fields from one column to another in Access

Below i have a table where i need to get fields from one column to three columns.
This is how i would like the data to end up
Column1
Music
Column2
com.sec.android.app.music
Column3
com.sec.android.app.music.MusicActionTabActivity
Give the table a numeric autonumber id
Remove the rows with no data with a select where blank spaces or null
Find records with no point in the content with a select
Use the previous query as a source and use the id to find the id + 1 to find the next record and do the same with + 2 to find the second row
Build a table to hold the new structure and use the query as a source to insert the new created data in the new table with the 3 columns structure.
This is an example using sql server
Test table design
Data in table
Query
Look at the query from the inside. The first query inside clean the null records. Then the second query find the records with out point. This records are the reference to find the related two records. Then the id of the records with out point are used to make a query in the select adding 1 for the next record and then other query adding 2 to find the other record. Now you only need to create a table to insert this data, using this query as the source.