Solved

VB Constants in text strings

Posted on 2012-03-13
4
232 Views
Last Modified: 2012-03-14
I use Visual Basic for SQL applications.  Most of the queries are dynamic, lengthy, and complex.  In Visual Studio 2005, I was able to construct the SQL statements with immbeded VB constants (eg. vbLf, vbTab).  During debugging, I could then copy the string value and paste it into SQL Management Studio.  The vb constants gave a formatted layout in SQLMS.

As a simple example:
dim strSql as string = "select a, b, c " + vbLf + "from xyz"

In Visual Studio 2010, the vb constants are ignored or replaced with blanks.  As a result, the query in SQL is not formatted at all.  The same occurs when I paste into Notepad.  Therefore, the formatting is being lost during the Visual Studio copy, and not during the paste.  I've tried all variants of the copy.

This isn't a huge problem, but it seems it should be easy to do.  Any suggestions?

Thanks, Dave
0
Comment
Question by:SkyGuyDave
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717663
This may not make any difference but + is used in C# for string concatenation and we use & in VB for concatenation though + works in most cases.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717666
Do you copy from the tool tip that shows the value when debugging? Did you try using the immediate window instead?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 37719624
I had the same problem. Instead of using ? strSQL, use this:

Debug.Print(strSQL)
0
 

Author Closing Comment

by:SkyGuyDave
ID: 37721410
Using Debug.Print() in the Immediate window worked perfectly.  Thanks, emoreau, for the solution.

Too bad it doesn't work from the "Copy" function from the tooltip, as it did in Visual Studio 2005.  That was really easy!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

803 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