Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I carry on a line?

Posted on 2006-10-23
13
Medium Priority
?
246 Views
Last Modified: 2010-04-23
Hi,

I have a long mysql query and woould like to break it up into lines.

How do I carry on a line in VB.  I have seen underscores being used "_"?

Please help?
0
Comment
Question by:nickmarshall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +3
13 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17788130
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17788135
{my personal preference, others may vary}

Dim sSQL as String

sSQL = "SELECT blah1, blah2, blah3 "
sSQL = sSQL & "FROM blahA "
sSQL = sSQL & "INNER JOIN blahB ON blahA.ID = blahB.ID "
sSQL = sSQL & "WHERE blah42='banana'"

0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17788174
or

        Dim SQL As New System.Text.StringBuilder

        SQL.Append("SELECT blah1, blah2, blah3 ")
        SQL.Append("FROM blahA ")
        SQL.Append("INNER JOIN blahB ON blahA.ID = blahB.ID ")
        SQL.Append("WHERE blah42='banana'")

        Console.Write(SQL.ToString)
0
Independent Software Vendors: 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!

 
LVL 9

Expert Comment

by:GivenRandy
ID: 17788193
I also do jimhorn's style, but in .NET it can be less typing if you use the "&=" instead (note that the string is initially assigned to String.Empty):

Dim sSQL as String = String.Empty

sSQL &= "SELECT blah1, blah2, blah3 "
sSQL &= "FROM blahA "
sSQL &= "INNER JOIN blahB ON blahA.ID = blahB.ID "
sSQL &= "WHERE blah42='banana'"
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17788317
Thanks experts, does this look right?....

        Dim SQL As String = String.Empty

        SQL &= " Insert Into Hardware (ID, CSName, CpuCurrenClockSpeed, CpuStatus,"
        SQL &= " CpuManufacturer, CpuName, CpuSocketDesignation, SystemName, "
        SQL &= " SystemOrganization, SystemRegisteredUser, SystemSerialNumber, "
        SQL &= " SystemTotalVisibleMemorySize, SystemWindowsDirectory, SoundManufacturer, "
        SQL &= +" SoundProductName, MotherboardManufacturer, MotherboardProduct)"
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 17788349
Looks okay except for the extra "+" in the last line.  Are you going to add the "VALUES" part, too?
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17788567
I have outputted the following query to the console;

        SQL &= "Insert Into Hardware (ID, CSName, CpuCurrenClockSpeed, CpuStatus, "
        SQL &= "CpuManufacturer, CpuName, CpuSocketDesignation, SystemName, "
        SQL &= "SystemOrganization, SystemRegisteredUser, SystemSerialNumber, "
        SQL &= "SystemTotalVisibleMemorySize, SystemWindowsDirectory, SoundManufacturer, "
        SQL &= "SoundProductName, MotherboardManufacturer, MotherboardProduct)"
        SQL &= "VALUES ("
        SQL &= "' ', '" & CSNameNode.InnerText & "', '" & CpuCurrentClockSpeed.InnerText & "', "
        SQL &= "' ', '" & CpuManufacturer.InnerText & "', '" & CpuName.InnerText & "', "
        SQL &= "' ', '" & CpuSocketDesignation.InnerText & "', '" & CpuStatus.InnerText & "', "
        SQL &= "' ', '" & SystemName.InnerText & "', '" & SystemOrganization.InnerText & "', "
        SQL &= "' ', '" & SystemRegUser.InnerText & "', '" & SystemSerialNumber.InnerText & "', "
        SQL &= "' ', '" & SystemTotVisMem.InnerText & "', '" & SystemWindows.InnerText & "', "
        SQL &= "' ', '" & SoundManufacturer.InnerText & "', '" & SoundProductName.InnerText & "', "
        SQL &= "' ', '" & MotherboardManufacturer.InnerText & "', '" & MotherboardProduct.InnerText & "', "
        SQL &= "' ', '" & DisplayDriver.InnerText & "', '" & DisplayName.InnerText & "' )"


The parts after the "VALUES", with the variables produce alot of errors, I get invalid formatting such as;

'F:\WINDOWS', ' ', 'Intel',

Where there are two  ' '

..and it should read 'F:\WINDOWS', 'Intel',
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17788616
       SQL &= "Insert Into Hardware (ID, CSName, CpuCurrenClockSpeed, CpuStatus, "
        SQL &= "CpuManufacturer, CpuName, CpuSocketDesignation, SystemName, "
        SQL &= "SystemOrganization, SystemRegisteredUser, SystemSerialNumber, "
        SQL &= "SystemTotalVisibleMemorySize, SystemWindowsDirectory, SoundManufacturer, "
        SQL &= "SoundProductName, MotherboardManufacturer, MotherboardProduct)"
        SQL &= "VALUES "
        SQL &= "( '" & CSNameNode.InnerText & "', '" & CpuCurrentClockSpeed.InnerText & "' "
        SQL &= ", '" & CpuManufacturer.InnerText & "', '" & CpuName.InnerText & "' "
        SQL &= ", '" & CpuSocketDesignation.InnerText & "', '" & CpuStatus.InnerText & "' "
        SQL &= ", '" & SystemName.InnerText & "', '" & SystemOrganization.InnerText & "' "
        SQL &= ", '" & SystemRegUser.InnerText & "', '" & SystemSerialNumber.InnerText & "' "
        SQL &= ", '" & SystemTotVisMem.InnerText & "', '" & SystemWindows.InnerText & "' "
        SQL &= ", '" & SoundManufacturer.InnerText & "', '" & SoundProductName.InnerText & "' "
        SQL &= ", '" & MotherboardManufacturer.InnerText & "', '" & MotherboardProduct.InnerText & "' "
        SQL &= ", '" & DisplayDriver.InnerText & "', '" & DisplayName.InnerText & "' )"
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17788657
Right got that working now however in some cases the variables produce an output as follows;

 'Gigabyte Motherboard', '          Windows XP Professional',

Therefore Windows XP Professional has many spaces, would this effect the query, or would mysql simply ignore the lines?
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17788720
This is causing sytax error when I try to execute the query.
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17788774
Here is what the string looks like;

Insert Into Hardware (ID, CSName, CpuCurrenClockSpeed, CpuStatus, CpuManufacturer, CpuName, CpuSocketDesignation, SystemName, SystemOrganization, SystemRegisteredUser, SystemSerialNumber, SystemTotalVisibleMemorySize, SystemWindowsDirectory, SoundManufacturer, SoundProductName, MotherboardManufacturer, MotherboardProduct) VALUES ('SUPPORT-PC ', '1716', 'GenuineIntel ', '                Intel(R) Celeron(R) CPU 1.70GHz', 'Socket 478 ', 'OK', 'Microsoft Windows XP Professional|F:\WINDOWS|\Device\Harddisk0\Partition2 ', 'Our company', 'The Hostmaster ', '55274-OEM-0014286-12345', '1048052 ', 'F:\WINDOWS', 'Intel ', 'Intel(r) 82801BA/BAM AC'97 Audio Controller', 'Gigabyte Technology Co., Ltd. ', '8ID533  ', '6.13.10.4109 ', 'NVIDIA Quadro4 NVS' )

As you can see there are gaps in the above, also there is a comma within a string.  Please help
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17792190
you should type the variables like this samplevar.innertext.trim
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 17792305
What is the exact error that you are getting? It looks like you have 17 items in the first section and 18 in the VALUES part.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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