Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:20:49+00:00 2026-06-02T02:20:49+00:00

I have a project where we use the SQL queries directly in the code.

  • 0

I have a project where we use the SQL queries directly in the code.

Dim strSQL As String = "SELECT P.NAME, C.ID, C.NAME" +
         "FROM PERSONS P " + 
"INNER JOIN CITIES " +
"ON P.IDCITY = C.ID" +
"WHERE P.ID = {0}"

Is a little bit ennoying to format such a query using “” and “+”
Is there a way to write the script “As Is” (from a SQL file), without reformating it?

I’d use

strSQL = My.Resources.SELECT_PERSON_WITH_CITY

but in debug I can’t see/modify the original query.

I know, I know, this is not a best practice using SQL directly, but however, I use what I have.

PS.

As Conor Gallagher mentioned, in C# there is a way to achieve this:

string x = @"
  my 
  name 
  is {0}";
string y = string.Format(x, "jimmy");

Does anyone know a VB.NET equivalent?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:20:50+00:00Added an answer on June 2, 2026 at 2:20 am

    I believe the answer in vb.net is actually No, you can’t create strings in vb.net over multiple lines without using ” and + etc. In C# you can span strings over multiple lines using the “@” escape character. Bit like this:

    string x = @"
      my 
      name 
      is {0}";
    string y = string.Format(x, "jimmy");
    

    But VB.Net doesn’t have an equivalent.

    Update

    As per D..’s comment below, Xml Literals could solve this problem. See http://www.codeproject.com/Articles/292152/Mutliline-String-Literals-in-VB-NET

    Basically, as per the link, you can do clever stuff like this using Xml Literals:

    Dim sourceText As String =
        <string>
            Imports Microsoft.VisualBasic
            Imports System
            Imports System.Collections
            Imports Microsoft.Win32
            Imports System.Linq
            Imports System.Text
            Imports Roslyn.Compilers
            Imports System.ComponentModel
            Imports System.Runtime.CompilerServices
            Imports Roslyn.Compilers.VisualBasic
    
            Namespace HelloWorld
              Module Program
                Sub Main(args As String())
                  Console.WriteLine("Hello, World!")
                End Sub
              End Module
            End Namespace
        </string>
    

    Update 2

    Been playing around with this a bit. XmlLiterals are actually really nice! If you wanted to add variables into the loop you can do stuff like this:

    Dim x As String
    Dim y As String
    y = "Jimmy"
    
    x = <string>
            Select *
            From Person
            Where Person.FirstName = <%= y %>
        </string>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use LINQ-SQL as my DAL, I then have a project called DB which
We have a Library Project that we use for all our central reused code
I unfortunately need to use 'native' sql queries for a portion of my project
I have a SQL Server Integration Services project which queries a SQL Server 2005
I have a project which exposes object model to use by different types of
I have an existing project repo which I use for project A, and has
I have a project which I am trying to use in another new project,
I have a project for school and I have to use Java. Recently I
I have a project in which I'd like to use some of the .NET
I have converted an Entity framework project to use POCO objects by removing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.