2016-1221

SQL SERVER:

SELECT
  CASE
    WHEN A.COLORDER=1
    THEN D.NAME
    ELSE ''
  END AS 表名,
  CASE
    WHEN A.COLORDER=1
    THEN ISNULL(F.VALUE,'')
    ELSE ''
  END        AS 表说明,
  A.COLORDER AS 字段序号,
  A.NAME     AS 字段名,
  CASE
    WHEN COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1
    THEN '√'
    ELSE ''
  END AS 标识,
  C 阅读全文>>
                
标签: SQLSERVER ORACLE 阅读:1941
2014-1202

做ASP.NET MVC开发的时候,经常会出现一下错误:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specifie 阅读全文>>

标签: SQL Network Interfaces, error: 26 阅读:4666
2014-0303

dedecms即织梦(PHP开源网站内容管理系统)。织梦内容管理系统(DedeCms) 以简单、实用、开源而闻名,是国内最知名的PHP开源网站管理系统,也是使用用户最多的PHP类CMS系统,近日,网友在dedecms中发现了全版本通杀的SQL注入漏洞,目前官方最新版已修复该漏洞,相关利用代码如下:

EXP:

Exp:plus/recommend.php?action=&aid=1&_FILES[type][tmp_name]=\'
  or mid 阅读全文>>
                        

DedeCMS全版本通杀SQL注入漏洞利用代码及工具
标签: DEDECMS注入漏洞和利用工具 DedeCMS全版本通杀SQL注入漏洞 阅读:6615
2013-1024

mysql计算GPS经纬度距离

DELIMITER $$
CREATEDEFINER=`root`@`localhost` FUNCTION`getDistance`(
lon1 float(10,7)
,lat1 float(10,7)
,lon2 float(10,7)
,lat2 float(10,7)
) RETURNSdouble
begin
declared double;
declareradius int;
setradius = 6378140; #假设地球为正球形,直径为6378140米
setd = (2*ATAN2(SQRT(SIN((lat1-lat2)*PI()/180/2)
*SIN((lat1-lat2)*P 阅读全文>>
                
标签: mysql php 经纬度坐标距离 sqlserver mssql oracle 阅读:6003
2013-0416
case when a is null then 0 else 1 end

上边是sql的三目运算符,可谓经典,如果a为空则返回0否则返回1


下边提供一个修改查询结果为其他值的方法

ISNull(a,'0')

如果a为空则返回0

标签: SQL 三目运算符 阅读:10633
2013-0226

SqlCacheDependency可以使缓存在数据库或者数据库某张表或者字段变化后让指定缓存失效。对于一些需要及时显示的信息比较有用。

需要.net2.0以后设sql server2005及以后版本支持。

首先配置web.config

<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="5000">
<databases>
<add connectionStringName="DefaultConnectio 阅读全文>>

标签: SqlCacheDependency 缓存 阅读:5600
2013-0117
SQL(通用于 SQL Server
SELECT FROM Table ORDER BY NewID()

LINQ
 t in Table orderby Guid.NewGuid()t

Lambda
Table.OrderBy(x=>Guid.NewGuid())


下面是随机取去前n条数据

SQL(通用于 SQL Server

SELECT TOP n FROM Table ORDER BY NewID()< 阅读全文>>
标签: SQL LINQ Lambda 阅读:17471
2011-1118
id是指当前数据news_id参数


方法一:


string preSql = "select top 1 * from news where news_id < " + id + " order by news_id DESC"

string nextSql = "select top 1 * from news where news_id > " + id + " order by news_id ASC"


方法二:


string preSql = "select * from [news] where news_id = (select MAX(news_id) from [news]  阅读全文>>
标签: SQL 阅读:6034