Click here to Skip to main content
15,881,882 members
Home / Discussions / Database
   

Database

 
AnswerRe: Update SQL Server Table with a Spreadsheet Worksheet DataTable using CommandBuilder Pin
Mycroft Holmes27-Jul-15 14:33
professionalMycroft Holmes27-Jul-15 14:33 
QuestionSQL Linq, Joins, returns 1st record over and over Pin
jkirkerx23-Jul-15 9:11
professionaljkirkerx23-Jul-15 9:11 
Answer[Solved] Pin
jkirkerx23-Jul-15 11:30
professionaljkirkerx23-Jul-15 11:30 
QuestionEntity Framework Book. Pin
Kevin Marois23-Jul-15 5:29
professionalKevin Marois23-Jul-15 5:29 
QuestionRe: Entity Framework Book. Pin
Richard MacCutchan23-Jul-15 6:36
mveRichard MacCutchan23-Jul-15 6:36 
AnswerRe: Entity Framework Book. Pin
Kevin Marois23-Jul-15 7:31
professionalKevin Marois23-Jul-15 7:31 
AnswerRe: Entity Framework Book. Pin
Mycroft Holmes23-Jul-15 14:10
professionalMycroft Holmes23-Jul-15 14:10 
QuestionSQL Linq, select from select and join Pin
jkirkerx21-Jul-15 13:27
professionaljkirkerx21-Jul-15 13:27 
Yes I did write this, I must of been on a roll. I understand what I wrote in TSQL, but I just can't wrap my head around how to write it in Linq.

TSQL
DECLARE @startDate AS DATETIME, @stopDate AS DATETIME; 
 SET @startDate = DATETIMEFROMPARTS(@Year, @Month, @Day, 0, 0, 0, 0); 
 SET @stopDate = DATETIMEFROMPARTS(@Year, @Month, @Day, 23, 59, 59, 999); 
 SELECT 
   TOP 20 
   CartID 
 , PartNumber 
 , Thumbnail 
 , SDescription 
 , Qty 
 , Price 
 , Category 
 , Date 
 , ProductID 
  FROM 
 ( 
    SELECT 
      sc.CartID 
    , sc.PartNumber 
    , sc.Thumbnail 
    , sc.SDescription 
    , sc.Qty 
    , sc.Price 
    , sc.Category 
    , sc.Date 
    , pi.productID 
    FROM ShoppingCart sc 
    LEFT JOIN PRODUCTINFO pi ON sc.PartNumber = pi.PartNumber 
    WHERE sc.Date > @startDate 
    AND sc.Date < @stopDate 
 ) x 
 ORDER BY Date 

Now I wrote this earlier as pResults = from Shopping cart with a join to products, so I can get the productID from products based on partNumber.
But the join or something was inconsistent according to the error. I was running 2 context. I put the product and cart tables in separate context.

So I was thinking perhaps I need to grab the Shopping cart data first, and then query those results with a join to products for the productID.

I have no clue how to phrase this.
This is what I have so far
Dim pValue As Integer = 0
        Dim DateStart As New Date(Now.Year, Now.Month, Now.Day, 0, 0, 0, 0)
        Dim DateStop As New Date(Now.Year, Now.Month, Now.Day, 23, 59, 59, 0)

        Dim productContext As New ProductContext()
        Dim shoppingContext As New ShoppingCartContext()

        Dim query = _
        (
            From sc In shoppingContext.ShoppingCart
            Where sc.CartDate >= DateStart _
            And sc.CartDate <= DateStop
            Take 20
            Select
            {
                sc.CartID,
                sc.PartNumber,
                sc.ThumbNail,
                sc.SDescription,
                sc.Qty,
                sc.Price,
                sc.Category,
                sc.CartDate
            }
        ).AsEnumerable()

In hindsight, I should of used the productID in the shoppingCart table.
SuggestionRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 1:50
mveRichard Deeming22-Jul-15 1:50 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 6:02
professionaljkirkerx22-Jul-15 6:02 
GeneralRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 8:00
mveRichard Deeming22-Jul-15 8:00 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 9:04
professionaljkirkerx22-Jul-15 9:04 
QuestionTrouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:08
professionaljkirkerx20-Jul-15 13:08 
AnswerRe: Trouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:34
professionaljkirkerx20-Jul-15 13:34 
Generalmake nullable type Pin
jkirkerx20-Jul-15 13:59
professionaljkirkerx20-Jul-15 13:59 
General[Got It] Pin
jkirkerx21-Jul-15 9:58
professionaljkirkerx21-Jul-15 9:58 
GeneralThe above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx22-Jul-15 8:54
professionaljkirkerx22-Jul-15 8:54 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Mycroft Holmes22-Jul-15 14:15
professionalMycroft Holmes22-Jul-15 14:15 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx23-Jul-15 6:38
professionaljkirkerx23-Jul-15 6:38 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Brisingr Aerowing23-Jul-15 7:37
professionalBrisingr Aerowing23-Jul-15 7:37 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx23-Jul-15 8:21
professionaljkirkerx23-Jul-15 8:21 
QuestionDatabase management Pin
Otekpo Emmanuel19-Jul-15 9:22
Otekpo Emmanuel19-Jul-15 9:22 
GeneralRe: Database management Pin
PIEBALDconsult19-Jul-15 9:40
mvePIEBALDconsult19-Jul-15 9:40 
AnswerRe: Database management Pin
Richard MacCutchan19-Jul-15 22:00
mveRichard MacCutchan19-Jul-15 22:00 
AnswerRe: Database management Pin
Mycroft Holmes19-Jul-15 22:32
professionalMycroft Holmes19-Jul-15 22:32 

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.