2013-02-22 23 views
0

我想把我的字符串放到几行中。我怎么能这样做? 这是我想要剪切的代码行(但它们仍然是字符串)。如何把另一行字符串(仍然在一个短语中)在vb.net?

sql = "INSERT INTO tblClientInfo (genClientID, fullName, address, comaker, colateral, atmPIN, principal, " 
       & "interest, principalInWords, terms, interestPerMonth, principalperMonth, totalPayment, interestPercentage, " 
       & " interestBal, principalBal, theDate, totalBal)" 

此代码返回错误。串联或切割长串的正确方法是什么?

+0

你之后的燕尾是“连续字符”。 http://msdn.microsoft.com/en-us/library/aa711641(v=vs.71).aspx – 2013-02-22 03:22:08

回答

2

您需要指示该行的后面添加每一行与一个空格下划线继续延续到下一行,如下所示:

sql = "INSERT INTO tblClientInfo (genClientID, fullName, address, comaker, colateral, atmPIN, principal, " _ 
    & "interest, principalInWords, terms, interestPerMonth, principalperMonth, totalPayment, interestPercentage, " _ 
    & " interestBal, principalBal, theDate, totalBal)" 

附加参考:http://msdn.microsoft.com/en-us/library/aa711641%28v=vs.71%29.aspx

+0

所以这就是它应该如何。很好说谢谢! – 2013-02-22 03:37:11

0

我像String.Concat(),因为你不需要连续下划线,你不需要&符号。看起来更干净。

sql = String.Concat( 
    "INSERT INTO tblClientInfo (genClientID, fullName, address, comaker, colateral, atmPIN, principal, ", 
    "interest, principalInWords, terms, interestPerMonth, principalperMonth, totalPayment, interestPercentage, ", 
    "interestBal, principalBal, theDate, totalBal)") 
+0

它返回语法错误...但我喜欢这个想法,如果它工作 – 2013-02-22 03:34:52

+0

@JayMarz奇怪的是,它为我工作。只要定义了'sql'。 – ThinkingStiff 2013-02-22 03:41:59

+0

我不知道。也许有什么东西需要导入或什么。 – 2013-02-22 03:55:19

相关问题