Thanks for the quick reply - I've had to change this now and use a stored procedure- something which I've never used - would I be right in doing this: I create a stored procedure:selecttblorders.orderid,customerid,invoiceid,tblmonths.monthidinto #tempcustomerfrom tblmonthsleft outer join tblinvoices on MONTH(tblinvoices.invoicedate) = tblmonths.monthidinner join tblorderson tblinvoices.orderid = tblorders.orderidwhere customerid = @clientid
(this in sql server asks me to declare @clientid but I want to declare that from my vb.net form)and then put this in my dataset:SELECT tblmonths.monthid, tblmonths.monthtext, #tempcustomer.customerid, SUM(tblinvoicedetails.qty * tblinvoicedetails.price) AS invoicetotal, #tempcustomer.invoiceidFROM tblmonthsleft outer join #tempcustomer on #tempcustomer.monthid = tblmonths.monthidleft outer join tblinvoicedetailson tblinvoicedetails.invoiceid = #tempcustomer.invoiceidGROUP BY tblmonths.monthid, tblmonths.monthtext, #tempcustomer.customerid, #tempcustomer.invoiceid
Thanks