Solved

VB Constants in text strings

Posted on 2012-03-13
4
234 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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