62,046
社区成员
发帖
与我相关
我的任务
分享
select TOP 10 字段名 (别名:XML中的节点名称) from 表名 for xml
DataTable table = new DataTable();
table.WriteXml(@"c:\temp.xml");
/// <summary>
/// 消息显示
/// </summary>
/// <param name="sets">数据集</param>
/// <param name="lie">要显示的列名</param>
/// <param name="parm">链接的参数(以键值对的形式来显示,键为参数名,值为该参数在table的列)</param>
/// <param name="url">要链接到的网页</param>
/// <param name="counts">每行显示的数据条数</param>
/// <returns></returns>
public static string GetAnnouncementJS(DataTable table, string lie,Hashtable parm,string url,int counts)
{
int i = 0;
StringBuilder AnnouncementJS = new StringBuilder();
AnnouncementJS.Append("<script language=\"JavaScript1.2\">" + "\n");
AnnouncementJS.Append("var delay=6000" + "\n");
AnnouncementJS.Append("var scrollwidth=210" + "\n");
AnnouncementJS.Append("var scrollheight=75" + "\n");
AnnouncementJS.Append("var message=new Array()" + "\n");
AnnouncementJS.Append("var openingtag='<font face=\"Arial\">'" + "\n");
for (int j = 0; j<table.Rows.Count;j++ )
{
string massges = "";
for (int b = 0; b < counts; b++)
{
string par = "";
if(j<table.Rows.Count){
DataRow row = table.Rows[j];
foreach (DictionaryEntry de in parm)
{
string lies = de.Value.ToString();
par += de.Key.ToString() + "=" + row[lies].ToString() + "&";
}
if (par.Length > 0)
{
par = par.Substring(0, par.Length - 1);
}
massges += "<a href=\"" + url + "?" + par + "\">" + row[lie].ToString() + "</a> ";
j++;
}
}
AnnouncementJS.Append("message[" + i + "]='" + massges + "'" + "\n");
i++;
}
AnnouncementJS.Append("var closingtag='</font>'" + "\n");
AnnouncementJS.Append("var hoffset=500" + "\n");
AnnouncementJS.Append("</script>" + "\n");
AnnouncementJS.Append("<ilayer width=&{scrollwidth}; height=&{scrollheight}; name=\"sslide\">" + "\n");
AnnouncementJS.Append("<layer name=\"sslide2\" width=&{scrollwidth}; height=&{scrollheight};></layer>" + "\n");
AnnouncementJS.Append("</ilayer>" + "\n");
AnnouncementJS.Append("<script language=\"JavaScript1.2\">" + "\n");
AnnouncementJS.Append("var inc=1" + "\n");
AnnouncementJS.Append("var ns4=document.layers" + "\n");
AnnouncementJS.Append("var ie5ns6=document.getElementById||document.all" + "\n");
AnnouncementJS.Append("if (ie5ns6)" + "\n");
AnnouncementJS.Append("document.write(openingtag+'<div id=\"flyin\" style=\"position:relative;width:'+scrollwidth+';height:'+scrollheight+';\">'+message[0]+'</div>'+closingtag)" + "\n");
AnnouncementJS.Append("function updatemsg(){" + "\n");
AnnouncementJS.Append("crossobj.style.left=200" + "\n");
AnnouncementJS.Append("crossobj.style.fontStyle=\"italic\"" + "\n");
AnnouncementJS.Append("crossobj.innerHTML=message[inc]" + "\n");
AnnouncementJS.Append("start=setInterval(\"animatein()\",50)" + "\n");
AnnouncementJS.Append("inc=(inc<message.length-1)? inc+1 : 0" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("function animatein(){" + "\n");
AnnouncementJS.Append("if (parseInt(crossobj.style.left)>0)" + "\n");
AnnouncementJS.Append("crossobj.style.left=parseInt(crossobj.style.left)-20" + "\n");
AnnouncementJS.Append("else{" + "\n");
AnnouncementJS.Append("crossobj.style.left=0" + "\n");
AnnouncementJS.Append("crossobj.style.fontStyle=\"normal\"" + "\n");
AnnouncementJS.Append("clearInterval(start)" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("function updatemsgns4(){" + "\n");
AnnouncementJS.Append("document.sslide.document.sslide2.document.write(openingtag+message[inc]+closingtag)" + "\n");
AnnouncementJS.Append("document.sslide.document.sslide2.document.close()" + "\n");
AnnouncementJS.Append("inc=(inc<message.length-1)? inc+1 : 0" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("function initialize(){" + "\n");
AnnouncementJS.Append("if (ie5ns6){" + "\n");
AnnouncementJS.Append("crossobj=document.getElementById? document.getElementById(\"flyin\") : document.all.flyin" + "\n");
AnnouncementJS.Append("setInterval(\"updatemsg()\",delay+1000)" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("else if (ns4){" + "\n");
AnnouncementJS.Append("document.sslide.document.sslide2.document.write(openingtag+message[0]+closingtag)" + "\n");
AnnouncementJS.Append("document.sslide.document.sslide2.document.close()" + "\n");
AnnouncementJS.Append("setInterval(\"updatemsgns4()\",delay)" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("}" + "\n");
AnnouncementJS.Append("window.onload=function() { initialize(); jiazai(); }" + "\n");
AnnouncementJS.Append("</script>" + "\n");
return AnnouncementJS.ToString();
}
public static void GetImgXml(DataTable table,string path) {
StringBuilder imgxml = new StringBuilder();
imgxml.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "\n");
imgxml.Append("<data speed=\"4\" but=\"750,510\" center=\"0\" rotundity=\"1,1,1,1\" style=\"0\" >" + "\n");
foreach(DataRow row in table.Rows){
imgxml.Append("<video imgURL=\"" + row["PicURL"].ToString() + "\" url=\"" + row["FujianURL"].ToString() + "\"/>" + "\n");
}
imgxml.Append("</data>" + "\n");
FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
StreamWriter writ = new StreamWriter(fs);
writ.Write(imgxml.ToString());
writ.Close();
fs.Close();
}
}