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)