It has been a while since I’ve had to write a rather long line in VB.NET and I forgot how to continue it on the following line so that it would not continue of the screen. My search on the web was fruitless (surprisingly), maybe I am a bad searcher, so I am writing this post.
Below is an example that will work on any long line of code that you wish to carry over to the next line.
I open Visual Studio 2005. This is an asp.net page with code included in the file.
An SQL query can get really complex and lengthy so breaking it out is easier. See the code below or the image.
strSQL = “Select cust_id, first_name, last_name, email, phone ” & _
“From customer01 ” & _
“Where email like ‘%@yahoo.com’”
You may be programming a page that does not use code behind. Luckily for these pages you do not have to use the concatenating characters of “& _”. As long as the SQL is within the quotes your page will work fine. See image below.
<asp:AccessDataSource ID=”AccessDataSource1″ runat=”server” DataFile=”~/App_Data/cust.mdb” SelectCommand=”SELECT [CUST_ID], [FIRST_NAME], [LAST_NAME], [EMAIL], [PHONE] FROM [CUSTOMER01]WHERE EMAIL LIKE ‘%@yahoo.com'”></asp:AccessDataSource>