How do I break up a long SQL Select onto multiple lines of code?

Posted on 2009-02-24
Last Modified: 2012-05-06
I have a long SELECT I would like to see all at once.

I have tried the code below, but that gets filled with squiggly lines and Visual Studio adds the quotation mark after JobID, like this....

        Dim JobCommand As String = "SELECT JobID, _"

        Dim JobCommand As String = "SELECT JobID, _
            JobTitle, _
            DateLastModified, _
            Employer.EmpID, _
            Employer.Emp_BusinessName _
            FROM [Jobs], [Employer] _
            WHERE Jobs.EmpID = Employer.EmpID AND"

The underscore works fine for breaking my Response.Write string over multiple lines.

SELECT JobID, _JobTitle, DateLastModified, Employer.EmpID, Employer.Emp_BusinessName FROM [Jobs], [Employer] WHERE Jobs.EmpID = Employer.EmpID AND

Open in new window

Question by:spaceneedlejumper
    LVL 10

    Accepted Solution

    Try this:
    Dim JobCommand As String = "SELECT JobID, " & _
        "JobTitle, " & _
        "DateLastModified, " & _
        "Employer.EmpID, " & _
        "Employer.Emp_BusinessName " & _
        "FROM [Jobs], [Employer] " & _
        "WHERE Jobs.EmpID = Employer.EmpID AND"

    Open in new window

    LVL 16

    Assisted Solution

      Dim JobCommand As String = "SELECT JobID, " & _
            "JobTitle, " & _
            "Employer.EmpID," & _
                "Employer.Emp_BusinessName" & _
                "FROM [Jobs], [Employer]" & _
                "WHERE(Jobs.EmpID = Employer.EmpID And '')
    LVL 10

    Assisted Solution

    Explanation: strings need to be closed with " before you can brake them in more lines

    Author Closing Comment

    You guys are savin' my bacon!

    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now