Click here to Skip to main content
15,900,907 members
Home / Discussions / Database
   

Database

 
QuestionKnowing if connection failed to sql server in C# Pin
pluss425-Aug-15 21:46
pluss425-Aug-15 21:46 
AnswerRe: Knowing if connection failed to sql server in C# Pin
Jörgen Andersson25-Aug-15 22:25
professionalJörgen Andersson25-Aug-15 22:25 
SuggestionRe: Knowing if connection failed to sql server in C# Pin
Richard Deeming26-Aug-15 2:20
mveRichard Deeming26-Aug-15 2:20 
GeneralRe: Knowing if connection failed to sql server in C# Pin
Jörgen Andersson26-Aug-15 2:43
professionalJörgen Andersson26-Aug-15 2:43 
GeneralRe: Knowing if connection failed to sql server in C# Pin
pluss426-Aug-15 8:08
pluss426-Aug-15 8:08 
Questionquestion for my new project Pin
turion8722-Aug-15 5:09
turion8722-Aug-15 5:09 
AnswerRe: question for my new project Pin
Wendelius22-Aug-15 5:58
mentorWendelius22-Aug-15 5:58 
AnswerRe: question for my new project Pin
Mycroft Holmes22-Aug-15 13:37
professionalMycroft Holmes22-Aug-15 13:37 
AnswerRe: question for my new project Pin
Jörgen Andersson23-Aug-15 21:09
professionalJörgen Andersson23-Aug-15 21:09 
AnswerRe: question for my new project Pin
GuyThiebaut25-Aug-15 2:53
professionalGuyThiebaut25-Aug-15 2:53 
QuestionER Diagram Pin
piiinku0021-Aug-15 15:53
piiinku0021-Aug-15 15:53 
AnswerRe: ER Diagram Pin
Jörgen Andersson23-Aug-15 22:21
professionalJörgen Andersson23-Aug-15 22:21 
QuestionJoining 4 Tables in SQL Server Pin
Member 1154678320-Aug-15 10:35
Member 1154678320-Aug-15 10:35 
AnswerRe: Joining 4 Tables in SQL Server Pin
Mycroft Holmes20-Aug-15 13:02
professionalMycroft Holmes20-Aug-15 13:02 
GeneralRe: Joining 4 Tables in SQL Server Pin
Member 1154678321-Aug-15 3:50
Member 1154678321-Aug-15 3:50 
GeneralRe: Joining 4 Tables in SQL Server Pin
Eddy Vluggen21-Aug-15 4:20
professionalEddy Vluggen21-Aug-15 4:20 
GeneralRe: Joining 4 Tables in SQL Server Pin
Mycroft Holmes21-Aug-15 14:16
professionalMycroft Holmes21-Aug-15 14:16 
GeneralRe: Joining 4 Tables in SQL Server Pin
Member 1154678321-Aug-15 23:14
Member 1154678321-Aug-15 23:14 
GeneralRe: Joining 4 Tables in SQL Server Pin
Mycroft Holmes22-Aug-15 1:09
professionalMycroft Holmes22-Aug-15 1:09 
GeneralRe: Joining 4 Tables in SQL Server Pin
Member 1154678323-Aug-15 4:25
Member 1154678323-Aug-15 4:25 
QuestionSSIS Error handling : Events vs control flow? Pin
Paddington Bear19-Aug-15 2:33
Paddington Bear19-Aug-15 2:33 
Questionsql linq, sum a column in a select new with Pin
jkirkerx16-Aug-15 12:39
professionaljkirkerx16-Aug-15 12:39 
I wrote this years ago for a report on total items sold, and I'm trying to convert it to a SQL Linq Statement in VB, but I think I'm way off here. Plus I'm not sure if I got the joins right, pretty sure that part should work.
SELECT 
  coH.PartNumber 
, coH.ManPartNumber 
, SUM(coH.Qty) as TotalQty
, CAST(SUM(coH.Qty * coh.Cost) AS Decimal(10,2)) as TotalCost 
, CAST(SUM(coH.Qty * coh.Price) AS Decimal(10,2)) as TotalPrice 

there must be a shorter way of writing the sum statement, and also I can't figure out how to sum the column within the select new. My original thought was to just think sql, but on the SUM, I think I need throw that idea out the window.
From cohc In context.Order_History_Cart
Join pi In context.ProductInfo On pi.PartNumber Equals cohc.PartNumber
Join vi In context.ProductInfo_Vendors On vi.VendorID Equals pi.VendorID
Where cohc.OrderDate >= m_startDate _
And cohc.OrderDate <= m_stopDate _
And cohc.PartNumber = p_PartNumber
Select New productItem With
{
   .m_partNumber = cohc.PartNumber,
   .m_manPartNumber = cohc.ManPartNumber,
   .m_totalQty = (From x In context.Order_History_Cart Where x.OrderDate >= m_startDate And x.OrderDate <= m_stopDate And x.PartNumber = p_PartNumber Select x.Qty).Sum(),
   .m_totalCost = (From y In context.Order_History_Cart Where y.OrderDate >= m_startDate And y.OrderDate <= m_stopDate And y.PartNumber = p_PartNumber Select (y.Qty * y.Cost)).Sum(),
   .m_totalPrice = (From z In context.Order_History_Cart Where z.OrderDate >= m_startDate And z.OrderDate <= m_stopDate And z.PartNumber = p_PartNumber Select (z.Qty * z.Price)).Sum(),
   .m_cost = pi.Cost,
   .m_price = pi.Price,

AnswerRe: sql linq, sum a column in a select new with Pin
chairborne8217-Aug-15 1:46
chairborne8217-Aug-15 1:46 
GeneralRe: sql linq, sum a column in a select new with Pin
Mycroft Holmes17-Aug-15 2:42
professionalMycroft Holmes17-Aug-15 2:42 
AnswerRe: sql linq, sum a column in a select new with Pin
Jörgen Andersson17-Aug-15 3:01
professionalJörgen Andersson17-Aug-15 3:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.