欢迎来到天天文库
浏览记录
ID:7866538
大小:25.87 KB
页数:15页
时间:2018-03-01
《vs2003(c#)学习心得(重点难点)》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、VS2003(C#)学习心得(重点难点)考虑问题步骤:SQL->Javascript->C#1.把数据库的多字段合并为一个字段显示与导出(也可以用String做:Strings+=sqlDr.GetString(i))出处:ERma/Apps/MCfg/QueryMcfg.aspx(1)protectedStringWriteAttributeCell(SqlDataReadersqlDr){intattributeCount=0;inti;Strings="";if(!sqlDr.IsDBNull(4)){attributeCount=sqlDr.GetInt32(4)
2、;if(attributeCount>0){for(i=0;i0){s+=";";}if(!sqlDr.IsDBNull(9+i)){s+=Server.HtmlEncode(sqlDr.GetString(9+i).Trim());}}}else{s+=" ";}}returns;}(2)String或StringBuilder对象的串联操作的性能取决于内存分配的发生频率。String串联操作每次都分配内存,而StringBuilder串联操作仅当StringBuilder对象缓冲区太小而无法容纳新数据时才分
3、配内存。因此,如果串联固定数量的String对象,则String类更适合串联操作。这种情况下,编译器甚至会将各个串联操作组合到一个操作中。如果串联任意数量的字符串,则StringBuilder对象更适合串联操作;例如,某个循环对用户输入的任意数量的字符串进行串联。SqlDataReadersqlDr=null;StringBuilderbufType=null;bufType=newStringBuilder();this.WriteAttributeCell(sqlDr,bufType);if(!sqlDr.IsDBNull(4)&&sqlDr.GetInt32(4)!
4、=0){ExcelDbTool.SetCommandParameterValue(oleCmd,7,this.bufType.ToString(),true);bufType.Remove(0,bufType.Length);}else{ExcelDbTool.SetCommandParameterValue(oleCmd,7,"",true);bufType.Remove(0,bufType.Length);}protectedvoidWriteAttributeCell(SqlDataReadersqlDr,StringBuilderbufType){intattri
5、buteCount=0;inti;if(!sqlDr.IsDBNull(4)){attributeCount=sqlDr.GetInt32(4);if(attributeCount>0){for(i=0;i0){bufType.Append(";");}bufType.Append(Server.HtmlEncode(sqlDr.GetString(9+i).Trim()));}}else{bufType.Append(" ");}}}(3)多字段合并为一个字段(SQL)selecttop2(rmanum+';
6、'+cast(accreditsiteidasnvarchar(100)))ashebinfromrmasys_3thrma結果:RUNW0708SNW189;-10RUWD0708SPW188;-82.用对话框弹出信息(1)this.msg=this["Msg_GenerateExcelException"]+""+e.Message;Response.Write("r");Response.Write("r");(2)Res
7、ponse.Write("");Response.Write("");Response.Write("Show:"+showQty.ToString()+";Hide:"+(recordCount-idx).ToString()+";Total:"+recordCount.ToString()+";Pleaseexporttoexceltoviewall(<65534)!");Response.Write("
此文档下载收益归作者所有