0

我想把我的绳子剪成几行。我怎么能那样做?这是我要剪切的代码行(但它们仍在字符串中)。

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

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

4

2 回答 2

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

于 2013-02-22T03:20:06.037 回答
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)" )
于 2013-02-22T03:24:27.507 回答