Click here to Skip to main content
15,889,865 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
Real Corks20-Mar-16 21:43
Real Corks20-Mar-16 21:43 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
CHill6020-Mar-16 22:41
mveCHill6020-Mar-16 22:41 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
Real Corks27-Mar-16 4:18
Real Corks27-Mar-16 4:18 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
CHill6027-Mar-16 5:29
mveCHill6027-Mar-16 5:29 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
Richard MacCutchan21-Mar-16 1:10
mveRichard MacCutchan21-Mar-16 1:10 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
Dave Kreskowiak21-Mar-16 2:47
mveDave Kreskowiak21-Mar-16 2:47 
GeneralRe: can someone help me to fix this? because i cannot make another xml file only the employee information Pin
Richard MacCutchan21-Mar-16 2:55
mveRichard MacCutchan21-Mar-16 2:55 
Questionvb.net 2010 has sql error Pin
dcof16-Mar-16 12:28
dcof16-Mar-16 12:28 
In a VB.NET 2010 application, I am trying to change the t-sql 2012 that is commented out for 'sql' to use the 'sql' that is not commented about below in the code. My goal is to use the original applications logic as much as possible.
I am trying to use a basic cte so that I can eventually list more columns in the original select statement and logic
after data is selected from the cte to list a sort column value. I know the code listed below does not work since the logic ends up in the try catch block. When I look at the 'sql' in the debugger, i so that there is no space in from of the FRom statement. The sql looks like
'STUDENTNAMEFROM'.

Thus could you tell me the following:

1. Could you show me how to modify the sql I listed below so that the CTE works in VB.NET 2010?
2. Could you tell me what I can do so the catch block will tell me what the exact error message is that is occuring?
#Region "Public Function SelectAttendanceLetters(ByVal schoolid As Integer, ByVal schoolyear As Integer) As DataTable"
    Public Function SelectAttendanceLetters(ByVal schoolid As Integer, ByVal schoolyear As Integer, ByVal milestone As Integer, ByVal term As Integer) As DataTable
        Dim dt As DataTable = New DataTable()

        'Const sql As String = "SELECT alm.SCHOOLYEAR, RTRIM(als.PERMNUM) AS PERMNUM, alm.SCHOOLNUM, alm.STULINK, alm.MILESTONE_CODE " _
        '    & ", RTRIM(als.LASTNAME) + ', ' + RTRIM(als.FIRSTNAME) + CASE WHEN MIDDLENAME IS NULL THEN '' WHEN RTRIM(MIDDLENAME) = '' THEN '' ELSE ' ' + SUBSTRING(RTRIM(MIDDLENAME), 1, 1) END AS STUDENTNAME " _
        '    & ", als.GRADE , alm.MILESTONE_DATE, alm.ABSENCES, alm.TARDIES, als.HOMELNGCOR, alm.SEMESTER " _
        '    & "FROM AtnLtrMilestone alm INNER JOIN AtnLtrASTU als ON alm.STULINK = als.STULINK " _
        '    & "WHERE alm.SCHOOLNUM = @schoolnum " _
        '    & "AND alm.SCHOOLYEAR = @schoolyear " _
        '    & "AND alm.MILESTONE_CODE = @milestone " _
        '    & "AND alm.SEMESTER = @semester " _
        '    & "AND (alm.PRINTED <> 'Y' OR alm.PRINTED IS NULL) " _
        '    & "AND (alm.PRINTED <> 'N' OR alm.PRINTED IS NULL) " _
        '    & "ORDER BY als.HOMELNGCOR, alm.MILESTONE_DATE, als.LASTNAME, als.FIRSTNAME, MIDDLENAME; "

        Const sql As String = ";WITH CTE_ASTU (SCHOOLYEAR,PERMNUM,SCHOOLNUM,STULINK,MILESTONE_CODE,STUDENTNAME,LASTNAME,FIRSTNAME,MIDDLENAME,GRADE,MILESTONE_DATE,ABSENCES,TARDIES,HOMELNGCOR,SEMESTER)  AS ( " _
          & "SELECT alm.SCHOOLYEAR as SCHOOLYEAR, RTRIM(als.PERMNUM) AS PERMNUM, alm.SCHOOLNUM as SCHOOLNUM, alm.STULINK as STULINK, alm.MILESTONE_CODE as MILESTONE_CODE " _
          & ", RTRIM(als.LASTNAME) + ', ' + RTRIM(als.FIRSTNAME) + CASE WHEN MIDDLENAME IS NULL THEN '' WHEN RTRIM(MIDDLENAME) = '' THEN '' ELSE ' ' + SUBSTRING(RTRIM(MIDDLENAME), 1, 1) END AS STUDENTNAME " _
          & ", als.LASTNAME as LASTNAME,als.FIRSTNAME as FIRSTNAME, CASE WHEN MIDDLENAME IS NULL THEN '' ELSE MIDDLENAME END AS MIDDLENAME " _
          & ", als.GRADE as GRADE , alm.MILESTONE_DATE as MILESTONE_DATE, alm.ABSENCES as ABSENCES, alm.TARDIES as TARDIES, als.HOMELNGCOR as HOMELNGCOR, alm.SEMESTER as SEMESTER" _
          & "FROM AtnLtrMilestone alm INNER JOIN AtnLtrASTU als ON alm.STULINK = als.STULINK " _
          & "WHERE alm.SCHOOLNUM = @schoolnum " _
          & "AND alm.SCHOOLYEAR = @schoolyear " _
          & "AND alm.MILESTONE_CODE = @milestone " _
          & "AND alm.SEMESTER = @semester " _
          & "AND (alm.PRINTED <> 'Y' OR alm.PRINTED IS NULL) " _
          & "AND (alm.PRINTED <> 'N' OR alm.PRINTED IS NULL) " _
          & ") " _
          & "SELECT * " _
          & " FROM CTE_ASTU " _
          & "ORDER BY HOMELNGCOR, MILESTONE_DATE, LASTNAME, FIRSTNAME, MIDDLENAME; "

     

        Using con As SqlConnection = DB.OpenConnectionCampusOPS()
            Using da As SqlDataAdapter = New SqlDataAdapter(sql, con)

                Try
                    da.SelectCommand.Parameters.Add("@schoolnum", SqlDbType.Int).Value = schoolid
                    da.SelectCommand.Parameters.Add("@schoolyear", SqlDbType.Int).Value = schoolyear
                    da.SelectCommand.Parameters.Add("@milestone", SqlDbType.Int).Value = milestone
                    da.SelectCommand.Parameters.Add("@semester", SqlDbType.Int).Value = term
                    da.Fill(dt)
                Catch ex As Exception

                End Try

            End Using
        End Using

        Return dt

    End Function
#End Region

AnswerRe: vb.net 2010 has sql error Pin
Mycroft Holmes16-Mar-16 23:08
professionalMycroft Holmes16-Mar-16 23:08 
AnswerRe: vb.net 2010 has sql error Pin
dcof17-Mar-16 8:43
dcof17-Mar-16 8:43 
Questionvb Pin
Member 1239502015-Mar-16 18:23
Member 1239502015-Mar-16 18:23 
AnswerRe: vb Pin
Mycroft Holmes15-Mar-16 20:04
professionalMycroft Holmes15-Mar-16 20:04 
AnswerRe: vb Pin
Patrice T19-Mar-16 12:09
mvePatrice T19-Mar-16 12:09 
QuestionNeed help on making a advanced internet based application? VB.NET Pin
Member 1237915715-Mar-16 18:07
Member 1237915715-Mar-16 18:07 
AnswerRe: Need help on making a advanced internet based application? VB.NET Pin
Mycroft Holmes15-Mar-16 19:59
professionalMycroft Holmes15-Mar-16 19:59 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Member 1237915716-Mar-16 2:58
Member 1237915716-Mar-16 2:58 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Dave Kreskowiak16-Mar-16 4:40
mveDave Kreskowiak16-Mar-16 4:40 
AnswerRe: Need help on making a advanced internet based application? VB.NET Pin
Patrice T16-Mar-16 14:56
mvePatrice T16-Mar-16 14:56 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Member 1237915716-Mar-16 22:26
Member 1237915716-Mar-16 22:26 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Patrice T16-Mar-16 22:55
mvePatrice T16-Mar-16 22:55 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Member 1237915716-Mar-16 23:39
Member 1237915716-Mar-16 23:39 
AnswerRe: Need help on making a advanced internet based application? VB.NET Pin
Patrice T17-Mar-16 0:09
mvePatrice T17-Mar-16 0:09 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Member 1237915717-Mar-16 0:23
Member 1237915717-Mar-16 0:23 
GeneralRe: Need help on making a advanced internet based application? VB.NET Pin
Richard MacCutchan17-Mar-16 2:56
mveRichard MacCutchan17-Mar-16 2:56 
Questionvb.net 2010 db error message Pin
dcof15-Mar-16 12:06
dcof15-Mar-16 12:06 

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.