Quantcast
Channel: Getting started with SQL Server forum
Viewing all articles
Browse latest Browse all 9243

Fill data grid with data from a JOIN query

$
0
0

I am working on a school project and have come up against a bit of a sticking point. I am supposed to be creating a very basic OMS, the teacher themselves have said they do not know how to do this (in previous years it has all be done via Access) but apparently I am a lucky one to be doing it in SQL this year. 

So I have 2 tables for products in the system 

products+-----------+------------+|productid  |productname ||Int        |varchar(50)|+-----------+------------+


productdetail
+---------+----------+------------+------+------+|detailId |productid |description |price |stock ||Int      |Int       |Text        |Money |Int   |||FK_From_  ||||||productid_||||||products  ||||+---------+----------+------------+------+------+

One of the user requirements of the OMS is to fill a data grid with product name and the product details which I have the query for or rather I have created a view for, which is then queried from a stored procedure. 

CREATE VIEW [dbo].[v_stock]
	AS SELECT        tab_products.productname, tab_productdetails.description, tab_productdetails.image, tab_productdetails.price, tab_productdetails.stock
	FROM			 tab_productdetails INNER JOIN
                         tab_products ON tab_productdetails.productid = tab_products.productid

The problem I am having is then returning the data from this query into a data grid, I think the reason is because when I attached the stored procedure to a table and then call that procedure via the table adapter there is a mismatch of the schema - specifically the table it is attached to does not contain the column "productName". 

I am thinking I need to create a temporary table to fill the data grid with - however, I am not sure how I would create a temporary table. 

Is there something I am missing or not done correctly. As far as I can tell the queries work as when I preview them they produce the expected results. 

Thanks in advance. 


Viewing all articles
Browse latest Browse all 9243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>