Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27517

VS 2012 Select only certain records (batch)

$
0
0
I am trying to select on 30 (this will be adjusted with a variable) records at a time. The selection works when I am not Joining two of my tables,

When I add the following JOIN, the Datagrid tells me that the field c.[Followup] does not exist.

Code:

JOIN  CallerTask1  c ON a.National_id = c.National_id
There is no problem with the other JOIN

Code:

Student a right JOIN  QUALIFICATION    b  ON a.[id] = b.[id] )
my problem is with this code??

Code:

WITH CTE AS ( SELECT *,  ROW_NUMBER() OVER (ORDER BY ID) AS RowNumber  FROM  [StuentPlacement20131].[dbo].[Student] )  SELECT * FROM CTE WHERE RowNumber BETWEEN  " & StartRow & "  AND " & EndRow & "
Is this conflicting with my JOIN's?

Code:

FieldsString = "a.[id] , a.[National_Id] , a.[Alternative_Id_Type], a.[Person_Alternate_Id] ,a.[Person_First_Name] , " & _
                      "a.[Person_Middle_Name], a.[Person_Last_Name], a.[Equity_Code] , a.[Person_Birth_Date] , " & _
                      "a.[Person_Title] , a.[Gender_Code] ,a.[Citizen_Resident_Status_Code] , a.[Disability_Status_Code], " & _
                      "a.[Home_Language_Code], a.[Nationality_Code], a.[Socioeconomic_Status_Code], a.[Person_Home_Address_1] , " & _
                      "a.[Person_Home_Addr_Postal_Code],a.[Person_Home_Address_2], a.[Person_Home_Address_3], " & _
                      "a.[Person_Postal_Address_1], a.[Person_Postal_Addr_Post_Code], a.[Municipality], a.[Person_Postal_Address_2],  " & _
                      "a.[Person_Postal_Address_3], a.[Province_Code], a.[Person_Phone_Number], a.[Person_Cell_Phone_Number], " & _
                      "a.[Person_Fax_Number], a.[Person_Email_Address], a.[Campus], a.[CollegeID],  a.[Level_grade], " & _
                      "a.[MainSubject1], a.[MainSubject2], a.[MainSubject3], a.[Mainsubject4], a.[NOTES],c.[FollowUp] ,c.[Complete] ,c.[NoAnswer] ,c.[CallerHangUp]  ,c.[CallBackPlease],c.[WrongNumber]"
        FinalSQL_Str = "  WITH CTE AS ( SELECT *,  ROW_NUMBER() OVER (ORDER BY ID) AS RowNumber  FROM  [StuentPlacement20131].[dbo].[Student] )  SELECT * FROM CTE WHERE RowNumber BETWEEN  " & StartRow & "  AND " & EndRow & " " & _
                "( SELECT distinct  " & FieldsString & " FROM Student a  right JOIN  QUALIFICATION    b  ON a.[id] = b.[id]  " & _
              " JOIN  CallerTask1  c ON a.National_id = c.National_id  where  " & SetaString & "  " & finaltask & ")"        myCommand = New SqlClient.SqlCommand(FinalSQL_Str & "order by [id]", con)
        adp2 = New SqlDataAdapter(myCommand)
        adp2.Fill(dt)
        Grid_Select_Student_For_Edit.DataSource = dt


Viewing all articles
Browse latest Browse all 27517

Latest Images

Trending Articles



Latest Images

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