摘要: /*=================== 导入/导出 Excel 的基本方法 ===================*/从Excel文件中,导入数据到SQL数据库中,很简单,直接用下面的语句:/*===================================================================*/--如果接受数据导入的表已经存在insert into 表 select * from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\test.xls 阅读全文
posted @ 2012-05-21 18:53 ChaunceyHao 阅读(262) 评论(0) 推荐(0)
摘要: --创建一个测试数据库CREATE DATABASE dbON(NAME=db,FILENAME='c:\db.mdf')LOG ON(NAME=db_log,FILENAME='c:\db.ldf')--备份并删除测试数据库BACKUP DATABASE db TO DISK='c:\a.bak' WITH FORMATDROP DATABASE db--创建一个文件结构相同,但物理文件位置不同的数据库CREATE DATABASE dbON(NAME=db,FILENAME='d:\db.mdf')LOG ON(NAME=db 阅读全文
posted @ 2012-05-21 18:53 ChaunceyHao 阅读(155) 评论(0) 推荐(0)
摘要: using System; using System.Collections; using System.Threading; class ObserverPattern { //Observer Pattern Judith Bishop Jan 2007 // The Subject runs in a thread and changes its state // independently. At each change, it notifies its Observers. class Subject { public delegate void Callback (stri... 阅读全文
posted @ 2012-05-21 18:52 ChaunceyHao 阅读(169) 评论(0) 推荐(0)
摘要: using System;using System.IO;using System.Reflection;using System.Runtime.Serialization;using System.Runtime.Serialization.Formatters.Binary;using System.Security.Cryptography;namespace APress.SignAndSeal{ public class NotSerializableException : ApplicationException { public NotSerializableExceptio. 阅读全文
posted @ 2012-05-21 17:33 ChaunceyHao 阅读(317) 评论(0) 推荐(0)
摘要: using System;using System.Reflection;using System.Runtime.Remoting;using System.Threading;using System.Security.Permissions;using System.Security.Policy;using System.Security.Principal;namespace PPLauncher{ class LauncherClass { [STAThread] static void Main(string[] args) { try { AppDomain... 阅读全文
posted @ 2012-05-21 17:32 ChaunceyHao 阅读(147) 评论(0) 推荐(0)
摘要: 获得数据库中所有数据库的名字:select name From sysdatabases 获得某个数据库中所有表的名字:select name from sysobjects where type='U'获得某个表中字段的名字:select name from syscolumns where id=object_id('表名')use masterif exists(SELECT * From sysdatabases where name='test3')drop database test3create database test3gous 阅读全文
posted @ 2012-05-21 17:30 ChaunceyHao 阅读(193) 评论(0) 推荐(0)
摘要: -- --Chapter 12 SQL code for the partitoned example.--USE AdventureWorks2008; -- Create the partition functionCREATE PARTITION FUNCTION [OrderDateRangePFN](datetime) AS RANGE RIGHT FOR VALUES (N'2001-01-01 00:00:00', N'2002-01-01 00:00:00', N'2003-01-01 00:00:00', N'2004- 阅读全文
posted @ 2012-05-21 17:24 ChaunceyHao 阅读(176) 评论(0) 推荐(0)
摘要: 1 #!/usr/bin/perl2 if(@ARGV<2){print "Usage: $0 <network> <port>\nExample: $0 10.*.*.* 80 or 10.4.*.* 80 or 10.4.3.* 80\n";exit;}3 else{4 use IO::Socket;5 $sIP="@ARGV[0]";6 $port="@ARGV[1]";7 ($ip1,$ip2,$ip3,$ip4)=split(/\./,$sIP);8 if($ip2 == '*' 阅读全文
posted @ 2012-05-21 10:52 ChaunceyHao 阅读(152) 评论(0) 推荐(0)
摘要: 1 import java.net.URL;2 import java.net.URLConnection;3 import java.io.*;4 import java.util.*;5 6 public class HTTPGET{7 public static void main (String [] Args){8 try{9 FileWriter file = new FileWriter( "OutFile" );10 PrintWriter OutputFile = new PrintWriter( file );11 12 URL url = new .. 阅读全文
posted @ 2012-05-21 10:52 ChaunceyHao 阅读(127) 评论(0) 推荐(0)
摘要: using System;using System.IO;using System.Security.Cryptography;using System.Text;namespace APress.DotNetSecurity.Chapter2.KeyXMLStrings{ class KeyXMLStringsTester { static void Main(string[] args) { try { RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)RSA.Create(); Console.Wri... 阅读全文
posted @ 2012-05-21 10:13 ChaunceyHao 阅读(123) 评论(0) 推荐(0)
摘要: using System;using System.IO;using System.Security.Cryptography;using System.Text;namespace APress.DotNetSecurity.Chapter2.RNGBasics{ class RNGBasicsTester { static void Main(string[] args) { try { Console.WriteLine("Creating an RNG off of CSP parameters..."); CspParameters csp = new Csp.. 阅读全文
posted @ 2012-05-21 09:57 ChaunceyHao 阅读(137) 评论(0) 推荐(0)
摘要: declare @t table(编号 varchar(6),名称 varchar(6),数量 int)insert @t select '001', 'AAA', 10union all select '001', 'AAA', 3union all select '001', 'AAA', 50union all select '001', 'AAA', 70union all select '001', 'AAA', 18unio 阅读全文
posted @ 2012-05-21 09:54 ChaunceyHao 阅读(174) 评论(0) 推荐(0)
摘要: 返回指定表达式中某模式第一次出现的起始位置;如果在全部有效的文本和字符数据类型中没有找到该模式,则返回零。Transact-SQL 语法约定语法PATINDEX ( '%pattern%' , expression )备注如果 pattern 或 expression 为 NULL,则当数据库的兼容级别为 70 时,PATINDEX 将返回 NULL;如果数据库兼容级别小于或等于 65,则仅当 pattern 和 expression 同时为 NULL 时,PATINDEX 才返回 NULL。PATINDEX 基于输入的排序规则执行比较。若要以指定排序规则进行比较,则可以使用 阅读全文
posted @ 2012-05-21 09:52 ChaunceyHao 阅读(170) 评论(0) 推荐(0)
摘要: USE architectureChaptergo--------------------------------- GetToken user-defined function-------------------------------IF EXISTS(SELECT * FROM sys.assemblies WHERE name = 'UDFGetToken')BEGIN DROP FUNCTION dbo.GetToken DROP ASSEMBLY UDFGetTokenENDCREATE ASSEMBLY UDFGetTokenFROM 'c:\ProDa 阅读全文
posted @ 2012-05-21 08:43 ChaunceyHao 阅读(212) 评论(0) 推荐(0)
摘要: using System;using System.Data;using System.Data.Sql;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;using System.Text.RegularExpressions;namespace Apress.ProSqlServerDatabaseDesign{ //------------------------------------------------ // Purpose: Social Security number user-defined type . 阅读全文
posted @ 2012-05-21 08:39 ChaunceyHao 阅读(135) 评论(0) 推荐(0)
摘要: /*-----------------------------------------------Run before deploying CLR code using Visual Studio.If SQLCLR objects manually created, testTriggerCLR has already been created-----------------------------------------------*/USE architectureChaptergoCREATE TABLE dbo.testTriggerCLR(ssn varchar(11))go/* 阅读全文
posted @ 2012-05-21 08:38 ChaunceyHao 阅读(167) 评论(0) 推荐(0)
摘要: --建立測試環境Create Table department(departmenid Int,parentid Int)Insert department Select 60, nullUnion All Select 1, 0Union All Select 2, 1Union All Select 3, 1Union All Select 4, 2Union All Select 5, 2Union All Select 6, 3Union All Select 7, 3Union All Select 8, 7GO--建立函數Create Function F_GetParent(@d 阅读全文
posted @ 2012-05-21 08:33 ChaunceyHao 阅读(102) 评论(0) 推荐(0)
摘要: sp_MSforeachdbleo_lesley 11:21:18mssql里sp_MSforeachtable和sp_MSforeachdb的用法从mssql6.5开始,微软提供了两个不公开,非常有用的系统存储过程sp_MSforeachtable和sp_MSforeachdb,用于遍历某个数据库的每个表和遍历DBMS管理下的每个数据库。我们在master数据库里执行下面的语句可以看到两个proc详细的代码use masterexec sp_helptext sp_MSforeachtableexec sp_helptext sp_Msforeachdbsp_MSforeachtable系统 阅读全文
posted @ 2012-05-21 08:33 ChaunceyHao 阅读(164) 评论(0) 推荐(0)
摘要: using System;using System.Drawing;namespace Wrox.ProCSharp.StaticConstructorSample{ public class UserPreferences { public static readonly Color BackColor; static UserPreferences() { DateTime now = DateTime.Now; if (now.DayOfWeek == DayOfWeek.Saturday || now.DayOfWeek == DayOfWeek.Sunday) BackColor . 阅读全文
posted @ 2012-05-21 08:24 ChaunceyHao 阅读(110) 评论(0) 推荐(0)
摘要: 随着New iPad的发布,平板也将逐渐进入Retina时代,在高分辨率设备里图片的显示效果通常不尽人意,为了达到最佳的显示效果就需要对图片进行优化,这里介绍一些优化方法: 一、用CSS替代图片 这一点在任何时候都适用;只是在当前我们可以更多的使用样式表来制作出设计效果,CSS3的圆角、渐变、模盒阴影、字体阴影能帮助我们处理绝大多数视觉效果,并且在各种分辨率下都有良好的表现。 CSS Button 二、为高分辨率设备提供高清图片 如果必须使用图片,通常是准备2套图片,一套原始尺寸( 为普通设备准备 ),一套两倍尺寸( 为高分辨设备准备 ),再根据设备的分辨率调用不同的图片,调... 阅读全文
posted @ 2012-05-21 01:09 ChaunceyHao 阅读(307) 评论(0) 推荐(0)
摘要: 移动web的调试一直是个难题,前期可以使用模拟器来协助调试,但到了真机调试阶段就让人非常头痛。而Weinre就是解决这难题的利器。 Weinre的本意是Web Inspector Remote,它是一种远程调试工具。功能与Firebug、Webkit inspector类似,可以帮助我们即时更改页面元素、样式,调试JS等,下面就简单介绍下如何使用。 一、安装及运行Weinre 首先下载Weinre: https://github.com/callback/callback-weinre/archives/master 以Windows系统为例: 1.下载Weinre的Java版... 阅读全文
posted @ 2012-05-21 01:09 ChaunceyHao 阅读(562) 评论(0) 推荐(0)
摘要: 前段时间介绍了使用Weinre来调试Mobile Web的方法,而Adobe在3月份也推出了基于Weinre的的调试用具——Shadow,随着Release 2版的发布,Shadow在功能和体验上都有不错的表现,这里就做个简单的介绍。 一、部署Shadow: 相比Weinre,Shadow的部署可以用简单、轻松来形容,3步搞定: 访问Adobe Shadow官方下载页,下载并安装PC端程序:Shadow(支持Win、Mac,但不支持win xp)下载安装移动端应用程序:Shadow Mobile Device Client(支持iOS、Android平台),在下载页可以找到链相... 阅读全文
posted @ 2012-05-21 00:49 ChaunceyHao 阅读(403) 评论(0) 推荐(0)