SQL语句查询某表中所有字段的名称、类型、长度等属性信息

数据库:Sqlserver
SQL语句:

SELECT  
字段名=a.name,
标识=case when COLUMNPROPERTY(a.id,a.name,'IsIdentity')=1 then '√'else '' end,
主键=case when exists(SELECT 1 FROM sysobjects where xtype='PK' and name in (SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid))) then '√' else '' end,
类型=b.name,
占用字节数=a.length,
长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),
小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
允许空=case when a.isnullable=1 then '√'else '' end,
默认值=isnull(e.text,''),
字段说明=isnull(g.[value],'')
FROM syscolumns a
left join systypes b on a.xtype=b.xusertype 
inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' 
left join syscomments e on a.cdefault=e.id 
left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id 
left join sys.extended_properties f on d.id=f.major_id and f.minor_id =0 
Where d.name='Table_Name'
Order by a.name

window.onload与$(document).ready()差异对比

一,执行时机
window.onload():在页面所有元素(包括图片,引用文件)加载完后执行。
$(document).ready():页面中所有HTML DOM,CSS DOM结构加载完之后就会执行,其他图片文件可能没有加载完。

二,编写个数
window.onload(): 不能同时写多个,后面的将会覆盖前面的。

window.onload=function(){ 
    alert("A"); 
}
window.onload=function(){ 
    alert("B"); 
}

结果会执行“B”,如果想要顺序执行alert("A")和alert("B")需写成:

window.onload=function(){
    alert("A");
    alert("B");
}

$(document).ready(): 可以同时写多个,以下代码正确执行。

$(document).ready(function (){
   alert("Hello World!"); 
});
$(document).ready(function (){
   alert("Helllo World!"); 
});

三,简写方法
window.onload(): 无简写,但有相关写法。

$(window).load(function () {
});
// 等价于
window.onload = function () {
};

$(document).ready(): 有简写

$(document).ready(function(){
  //to do;
});

可写成

$().ready(function(){   //$()不带参数默认是document
  //to do;
});

$(function(){
  //to do;
});

js插件Autosize实现textarea标签高度自适应,且取消右边滚动条

Autosize插件官方:https://github.com/jackmoore/autosize
案例代码:

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<title>Simple Autosize for textareas</title>
<style>
    textarea {
        padding: 10px;
        vertical-align: top;
        width: 200px;
        resize:none;
        outline:none;
    }
    textarea:focus {
        outline-style: solid;
        outline-width: 2px;
    }
</style>
</head>
<body>
    <h3>max-height 300px</h3>
    <textarea style='max-height: 300px'>The coconut palm (also, cocoanut), Cocos nucifera, is a member of the family Arecaceae (palm family). It is the only accepted species in the genus Cocos.[2] The term coconut can refer to the entire coconut palm, the seed, or the fruit, which, botanically, is a drupe, not a nut. The spelling cocoanut is an archaic form of the word.[3] The term is derived from 16th-century Portuguese and Spanish coco, meaning "head" or "skull",[4] from the three small holes on the coconut shell that resemble human facial features.</textarea>

    <h3>no max-height</h3>
    <textarea>The coconut palm (also, cocoanut), Cocos nucifera, is a member of the family Arecaceae (palm family). It is the only accepted species in the genus Cocos.[2] The term coconut can refer to the entire coconut palm, the seed, or the fruit, which, botanically, is a drupe, not a nut. The spelling cocoanut is an archaic form of the word.[3] The term is derived from 16th-century Portuguese and Spanish coco, meaning "head" or "skull",[4] from the three small holes on the coconut shell that resemble human facial features.</textarea>
</body>
<script src='/autosize.min.js'></script>
<script>
    autosize(document.querySelectorAll('textarea'));
</script>
</html>

Autosize下载:autosize.zip 最好去下载官方最新的版本。

注意,以上案例代码中,还用css3样式去掉textarea标签的右下角拖动元素修改尺寸大小属性(resize:none)和轮廓线(outline:none)。

web.config配置文件中特殊字符的处理

在安装一个ASP.NET网站时,遇到问题,首先打开网站首页时,报错如下:
配置文件的XML格式不正确.png
然后在IIS里随便点击其他配置,比如默认文档,也会弹错:
web.config配置xml格式不正确.png
仔细看错误提示,发现sqlserver的数据库配置那一行标红了,然后反复试账号和密码的对错,没有解决问题。然后再网上看到我现在红框标注的地方:配置文件的XML格式不正确,这才是关键。





阅读剩余部分

帝国CMS列表模板list.var使用程序代码

1、增加模板时list.var模板需要勾选“使用程序代码”选项。
2、直接添加PHP代码,不需要加<??>程序开始和结束标记。
3、字段值数组变量为$r,对应的字段变量为$r[字段名],如:标题字段变量就是$r[title]。另外编号变量为$no。
这只是读取当前主表字段,如果是附表,要用副表或者其他表的字段值,要先用SQL取
4、将最终模板内容赋给$listtemp变量。





阅读剩余部分