vb.net - How can I join data like this in SQL Server, then display in my app? -


i trying figure out how query 2 columns table , join results records different table , display these items in gridview using visual studio (express 2013 web).

additional explanation:

i have several projects in project_table each have unique project_id. project_id project_table foreign key project_codes_table. each project_code has unique project_code_id. each project can have several different project_codes associated it. results in gridview should similar

| project id | projcode1 | projcode2 | projcode3 | 

but, if project_id found in project_codes table.

i assuming can each project_code in own query getting value if project_code_id matches value ... each query tied project_table display values in row. have pretty idea how in microsoft access have little clue how attempt using sql or visual studio.

use linq sql, , set datagridview.datasource = query result

  1. right click on project in solution explorer, , click add new item... select linq sql classes.
  2. from server explorer, either use existing data connection or right click , add new data connection. connect sql database.
  3. navigate through data connection until see tables want query from. drag each table included in query data classses pane.

in code want populate datatable, put similar code

using dc new dataclasses1     dim res = pt in dc.project_table               join pc in dc.project_codes on pc.id equals pt.project_code_id               select new {                   .projectid = pc.id,                   .projectcode1 = pc.projcode1                   } ' etc.     datagridview1.datasource = res end using 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -