trying to concatenate the string but got error
HI I am trying to concatenate the string but i got error at this line
sql += " "+"WHERE memberToMship_PayMethod="' +Cash"'";
like too many characters in character literal....
can any one help on this pls ......
sql = @"SELECT members.member_Id, members.member_Lastname, members.member_Firstname, members.member_IsBiometric";
sql += ","+"members.member_Reference, members.member_Dob, mem开发者_JS百科bers.member_PostCode, mshipstatustypes.mshipStatusType_Name, mshiptypes.mshipType_Name";
sql += ","+"membertomships.memberToMship_EndDate";
sql += " "+"FROM members LEFT JOIN membertomships ON membertomships.member_Id = members.member_Id";
sql += " "+"LEFT JOIN mshipstatustypes ON mshipStatusType_Id = membertomships.mshipStatusType_Id";
sql += " "+"LEFT JOIN mshipoptions ON mshipoptions.mshipOption_Id = membertomships.mshipOption_Id";
sql += " "+"LEFT JOIN mshiptypes ON mshiptypes.mshipType_Id = mshipoptions.mshipType_Id";
sql += " "+"WHERE memberToMship_PayMethod="' +Cash"'";
sql += " "+"WHERE memberToMship_PayMethod="' +Cash"'";
should probably be
sql += " "+"WHERE memberToMship_PayMethod='" +Cash+ "'";
or
sql += " "+"WHERE memberToMship_PayMethod='Cash'";
You've got a quote outside the double quotes, and you were missing a +
. Try this:
sql += " "+"WHERE memberToMship_PayMethod='" + Cash + "'";
try with
sql = @"SELECT members.member_Id, members.member_Lastname, members.member_Firstname, members.member_IsBiometric";
sql += ","+"members.member_Reference, members.member_Dob, members.member_PostCode, mshipstatustypes.mshipStatusType_Name, mshiptypes.mshipType_Name";
sql += ","+"membertomships.memberToMship_EndDate";
sql += " "+"FROM members LEFT JOIN membertomships ON membertomships.member_Id = members.member_Id";
sql += " "+"LEFT JOIN mshipstatustypes ON mshipStatusType_Id = membertomships.mshipStatusType_Id";
sql += " "+"LEFT JOIN mshipoptions ON mshipoptions.mshipOption_Id = membertomships.mshipOption_Id";
sql += " "+"LEFT JOIN mshiptypes ON mshiptypes.mshipType_Id = mshipoptions.mshipType_Id";
sql += " "+"WHERE memberToMship_PayMethod='" + "Cash" + "'";
actually you don't need to concate, you query is simple so you could use:
sqlQuery = @"Select * from ...........
..........................
where CashMethod="+Cash;
精彩评论