通常来说如果一个字符串a比较长,需要跨行,那可以写成 string a=@"xxxx
                                                         xxxxxxx";但是用了跨行字符@以后就没办法再用"+b+"加入变量了。请问有什么好办法吗
我现在想实现的是将以下sql中的value都换成变量
   string updateQuest = @"insert into Guests
                                      (Account, CardId, ArrivalDate, ArrivalTime, DepartureDate, DepartureTime, 
                                       GroupAccount,Status, PrimaryAccount, 
                                       RoomType, RoomNo, Adults, Children, RateCode, MarketCode, Rate, OverrideCode, 
                                       MOSCode, ContractId, ControlCode, ProfileNo, SalemanId, 
                                       CancelTime, CheckIn, FlightNo, ComeFrom, LeaveFor, Comment, Custom, Secret,
                                       MemberNo,  VisaType,  VisaNo, VisaDepart, ExpireDate, EntryPort, EntryDate, 
                                       EntryIdentity,  ReceivedCorp, StayPurpose, DomesticAddr, Packages, FirstName, 
                                       LastName, CreditCardType, CreditCardNo, VIPCode, Sex, 
                                       SourceCode,  Birthday, CertType, CertNO, Nationality, Address, 
                                       PostalCode, Company, Phone, LanguageCode, EmailAddress, PreferRoom, 
                                       PreferStyle, SpecialHabbit,  City, ResvRooms, ResvType, ResvMan, ResvDate,
                                       ResvManContactInfo,CCExpireDate, CmsnCode, CmsnRefAmount, VisaDate, 
                                       VisaNum,ResvNo,Rank,DiscountRate,Discount,BatchAccount,CCHolder,CentralProfileNo,
                                       CentralResvNo,CentralCancelNo,FlightArrivalDate,FlightArrivalTime,UDFText1,
                                       UDFText2,UDFText3,UDFDate1,UDFDate2,UDFDate3,Nation,State,ResvAssureMethod,
                                       ResvAssureContent,SpellCode,F_ProfileNote,F_Activity,F_Location,F_GuestMessage,
                                       F_Trace,F_Request,F_ChargeRoute,FixedRate,ExtraRate)
                                    values
                                      ('G000035519', NULL, '20070927 00:00:00.000', '16:19', '20070928 00:00:00.000', '12:00', 
                                    'R000000003', 'R', 
                                       'G000035519','NAT', '144', 1, 0, 'RAK', 'AOM', 
                                       1078.0, '1', 'CA', 'M000000246', 'D', 
                                       'P000174962', 'FO', NULL, 1, NULL, NULL, 
                                       NULL, '这里是备注', NULL, 0,  '0019491111',  NULL,  NULL,    
                                       NULL, NULL, NULL, NULL, NULL,  NULL, 
                                       NULL, NULL, '13;14', '人名', '姓别', '611', 
                                       '1000', 'VIP1', 0,  '03', '19821003 00:00:00.000', '33', '310115821003323',
                                       'CN', '浦东新区', NULL, NULL, '58457962', '01', 
                                       NULL, NULL, NULL,  NULL, NULL, 1,
                                       'WLK', NULL, '20070.000',NULL,'20071114 ,
                                       NULL, NULL, NULL, NULL,35519,NULL,NULL,
                                       NULL, NULL, '自己', NULL, NULL, NULL,
                                       NULL, NULL, NULL, NULL, NULL,
                                       NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                       NULL, NULL, NULL, NULL, NULL, NULL, NULL,

解决方案 »

  1.   

    string value1="lsdf";
    string   updateQuest   =   @ "insert   into   Guests ("+value1+","+ value2+",)";这样不行?
      

  2.   

    没什么不可以的string value = textBox1.Text;
    string test = @"this is
                          a test. " + value + @", the other
                       line";
      

  3.   

    不需要用@换行啊,例如
     aaa = "asdfasdf" +
                    "sfeghh" + "e33" +
                    "asdfr44444";
    aaa的数值就是所有的相加,那么中间穿插变量也肯定是可以的啊。不需要用@
      

  4.   

     StringBuilder sb = new StringBuilder();
                        sbSheBao.Append("update Table set property1=")
                                .Append(value1)
                                .Append(", property2=")
                                .Append(value2)
                                .……………………;这样应该就解决了你的问题,不知道我李解的对不对?1
                                
      

  5.   

    拼SQL最好用SqlParameter吧~~~~如果不使用也应该用StringBuilder.AppendFormat的办法吧??