Development issue "-" appears before---database field (save retention, for reference only)

Source: Internet
Author: User
Tags rtrim

Development-time data calls tend to use placeholders, but just beginning with a SQL statement that is easy to run into when you query the server to display "-", the following code:

#region first determine if there is a record, and then decide which command to use//query the database 20140713 CommandText = "Using ZZBJCDZZ select *" + "from [T_villagebasicinfo]" + "Where LTrim (RTrim ([code]) = ' {0} '";//Note parameter CommandText = String.Format (CommandText, Roo T.selectsinglenode ("Region"). InnerText);//Execute Query datatable = Dataengine.select (CommandText, out execright, out retmsg);//If present, use Update//20140 714 Error ================================if (DataTable.Rows.Count > 0) {//query database CommandText = "Use Zzbjcdz z Update [T_villagebasicinfo] "+" set [population]={0},[area]={1},[describes]= ' {2} ', [date]= ' {3} ', [lead Ingindustry]= ' {4} ', [annualincome]={5},[award]= ' {6} ', [teamsubsidy]={7},[partybuildtotalnum]={8} ' + ' where LTrim (             RTrim ([Code])) = ' {9} '; Note CommandText = String.Format (CommandText, Root. selectSingleNode ("Population"). InnerText, Root. selectSingleNode ("area"). Innertext,root. selectSingleNode ("describes"). Innertext,root. selectSingleNode ("Date"). InnerText, Root. selectSingleNode ("Leadingindustry"). Innertext,root. selectSingleNode ("Annualincome"). Innertext,root. selectSingleNode ("award"). InnerText, Root. selectSingleNode ("Teamsubsidy"). Innertext,root. selectSingleNode ("Partybuildtotalnum"). Innertext,root. selectSingleNode ("Region"). InnerText);} else{//Query Database CommandText = "INSERT INTO [T_villagebasicinfo] ([Population],[area],[code],[describes],[date], [Leadingindustry],[annualincome],[award],[teamsubsidy],[partybuildtotalnum]) VALUES ({0},{1}, ' {2} ', {3}, ' {4} ', ' {5 } ', ' {6} ', {7}, ' {8} ', {9},{10} ';//Note CommandText = String.Format (CommandText, Root. selectSingleNode ("Population"). Innertext,root. selectSingleNode ("area"). InnerText, Root. selectSingleNode ("Region"). Innertext,root. selectSingleNode ("describes"). InnerText, Root. selectSingleNode ("Date"). InnerText, Root. selectSingleNode ("Leadingindustry"). InnerText, Root. selectSingleNode ("Annualincome"). InnerText, Root. selectSingleNode ("award"). InnerText, Root. selectSingleNode ("Teamsubsidy"). InnerText, Root. selectSingleNode ("Partybuildtotalnum"). InnerText);} Execute Query Dataengine.execute (CommandText, out execright, out retmsg), if (Execright = true) {result = "<root>< Success>true</success><message> update Success </message></root> "; }else{result = "<root><success>false</success><message> update failed </message></root> "; }


If you are updating the database, the
<pre name= "code" class= "CSharp" >set [population]={0},[area]={1},[describes]= ' {2} ', [date]= ' {3} ', [ Leadingindustry]= ' {4} ', [annualincome]={5},[award]= ' {6} ', [Teamsubsidy]={7},[partybuildtotalnum]={8}


if ', ' written in Chinese will show '-' in front of the field.

(Give the code for everyone to refer to this replacement method)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.