存储过程中,t参许参数值的类型的意义

参许参数值的类型的意义如下:    
        名称值                           整数值                       功能    
    adDBTimeStamp             135                             日期时间数据类型    
    adDecimal                     14                               十进制整数值    
    adDouble                       5                                 双精度小数值    
    adError                         10                               系统错误信息    
        AdGUID                           72                               全域性唯一识别字(Globally   unique   identifier)    
        adDispath                     9                                 COM/OLE自动对象(Automation   Object)    
        adInteger                     3                                 4字节有符号整数    
        adIUnknown                   13                               COM/OLE对象    
        adLongVarBinary         205                             大型2字节值    
        adLongVarChar             201                             大型字符串值    
        adLongVarWChar           203                             大型未编码字符串    
        adNumeric                     131                             十进制整数值    
        adSingle                       4                                 单精度浮点小数    
        adSmallInt                   2                                 2字节有符号整数    
        adTinyInt                     16                               1字节有符号整数    
        adUnsignedBigInt       21                               8字节无符号整数    
        adUnsignedInt             19                               4字节无符号整数    
        adUnsignedSmallInt   18                               2字节无符号整数    
        adUnsignedTinyInt     17                               1字节无符号整数    
        adUserDefined             132                             用户自定义数据类型    
        adVariant                     12                               OLE对象    
        adVarBinary                 204                             双字节字符变量值    
        adVarChar                     200                             字符变量值    
        advarchar                     202                             未编码字符串变量值    
        adWchar                         130                             未编码字符串    
          
        方向值的意义如上:    
        名称值                           整数值                       功能    
        adParamInput               1                                 允许数据输入至该参数当中    
        adParamOutput             2                                 允许数据输出至该参数当中    
        adParamInputOutput   3                                 允许数据输入、输出至该参数当中    
        adparamReturnValue   4                                 允许从一子程序中返回数据至该参数当中    
  ————————————   
 第一个参数是变量名,第二个是类型,第三个输入输入参数,第4个是数据类型长度。

判断字段的值为空,asp.net

sf_img = Dr["sf_img"].ToString();

            if (sf_img != System.String.Empty)

{

}

初学数据库编程的人,经常会对“空值”产生疑问,例如通过编程新建的一个表中所有数据皆显示为,手动添加并删除文字后又变成了空白;一个字符串类型的字段,明明没有填值,却不等于"";用ADO.NET从数据库中取值,每遇到有的就出错……这需要我们正确认识.NET和SQL Server中几种不同的“空值”。

1:真正的空值

等同“没有输入的值”,可以出现在大多数类型的字段中(如果没有别的约束条件),SQL server中表示为null,显示为,手工在SQL server企业管理器中输入的方法是按Ctrl+0。它在.NET中对应System.DBNull.Value。在T-SQL命令中,判断一个值是不是空值,要用“is null”而不是“= null”;处理空值有个ISNULL函数,它使用指定的值替换null。用ADO.NET从数据库得到的空值无法自动转化为空字符串或Nothing,须手动检测:如果得到System.DBNull.Value,则赋给数据对象Nothing或其它自定义的有意义的值。

2:空字符串(零长度字符串),只出现在字符串类型(如nvarchar)的字段中,SQL server中表示为’’,显示为空白,手工在SQL server企业管理器中输入时清空一个单元格即可。它在.NET中对应System.String.Empty,也就是我们常用的""。在T-SQL命令中处理空字符串和处理一般的字符串没什么区别。用ADO.NET从数据库得到的空字符串也和一般的字符串没什么区别。
相关的概念还有VB.NET中的Nothing和对应于C#.NET中的null(注意这个null是C#.NET中的null而非SQL Server中null),它们在.NET中是表示不引用任何对象的空引用的值,在传入SQL server时,根据不同的上下文环境,可能存为真正的空值(比如在更新一个字符串类型的字段值时),也可能调用在SQL server中自定义的默认值(比如传给一个有默认值的存储过程参数),也可能因为无法进行类型转换而引发.NET异常。因此在用ADO.NET向SQL server中存储数据时,大家一定要小心使用Nothing。

Asp.net数组[转]

string[] abc=new string[8]{"1","2","3","4","1","2","3","4"};
Response.Write(Array.IndexOf(abc,"3",1));//在abc数组中查找"3",从abc[1]开始找
Response.Write(Array.LastIndexOf(abc,"3"));//在abc数组中查找"3",从最后开始找
——————————————————————————
string[] arrStr=new string[8]{"1","4","3","2","16","14","12","14"};//arrStr[0]="1"…arrStr[7]="14"
Array.Reverse(arrStr); //颠倒arrStr数组,此时arrStr[0]="14"…arrStr[7]="1"
Array.Sort(arrStr); //给数组排序,此时顺序为1,12,14,14,16,2,3,4(因为是按字符串排序)
——————————————————————————
Array型数组要重定义大小,必须用ReDim(VB),对于大数组会特别慢;且无法在中间插入元素;不能清除它们(只能设置为空或0)
ArrayList在使用上比Array慢,但是不用重定义大小,使用myArrList.Add("Dog")s可以方便的添加数据
ArrayList myArrList = new ArrayList();//不用指出数组的大小,而且每个元素可以是任意数据类型;
myArrList.Insert(1,"abc"); //插入元素到数组[1]前
myArrList.RemoveAt(1); //删除数组元素[1]
myArrList.Remove("abc"); //删除内容为"abc"的数组元素,只删除一次,如果要全删,需要做循环
——————————————————————————
 

将guest从administrator组中删除

机器被入侵过,把guest加入了administrators组中去了
想删掉,但是总是报“无法在内置帐户上运行此操作”的错误.

搜索了GOOGLE与百度,还没有发现有人提供完整的解决方案.

 打开注册表,找到HKEY_LOCAL_MACHINESAMSAM,单击鼠标右键,在弹出的子菜单中选择 权限 (WIN 2000的操作系统运行regedt32,找到HKEY_LOCAL_MACHINESAMSAM,选择 安全→权限),然后把你现在所使用的用户添加进入,并选择 完全控制,再刷新一下就可以看到SAM下面的项了

再找到HKEY_LOCAL_MACHINESAMSAMDomainsAccountUsers

Names就是你系统内的所有用户,Users是相对应的值

 

 

Guest相对应的项一般000001F5

删除下面的两项F,V .

在正常机器上导出这两项的值, 我从win2003导出的如下.可以将它复制另存.
导出方法:在 000001F5 上面右键 导出.

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESAMSAMDomainsAccountUsers00001F5]
"F"=hex:02,00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
  00,00,00,00,00,00,00,00,00,ff,ff,ff,ff,ff,ff,ff,7f,14,5d,a8,d6,98,de,c8,01,
  f5,01,00,00,01,02,00,00,15,02,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,
  00,00,00,00,00,00,00
"V"=hex:00,00,00,00,b0,00,00,00,02,00,01,00,b0,00,00,00,0a,00,00,00,00,00,00,
  00,bc,00,00,00,00,00,00,00,00,00,00,00,bc,00,00,00,22,00,00,00,00,00,00,00,
  e0,00,00,00,00,00,00,00,00,00,00,00,e0,00,00,00,00,00,00,00,00,00,00,00,e0,
  00,00,00,00,00,00,00,00,00,00,00,e0,00,00,00,00,00,00,00,00,00,00,00,e0,00,
  00,00,00,00,00,00,00,00,00,00,e0,00,00,00,00,00,00,00,00,00,00,00,e0,00,00,
  00,00,00,00,00,00,00,00,00,e0,00,00,00,00,00,00,00,00,00,00,00,e0,00,00,00,
  08,00,00,00,01,00,00,00,e8,00,00,00,04,00,00,00,00,00,00,00,ec,00,00,00,04,
  00,00,00,00,00,00,00,f0,00,00,00,04,00,00,00,00,00,00,00,f4,00,00,00,04,00,
  00,00,00,00,00,00,01,00,14,80,90,00,00,00,a0,00,00,00,14,00,00,00,44,00,00,
  00,02,00,30,00,02,00,00,00,02,c0,14,00,44,00,05,01,01,01,00,00,00,00,00,01,
  00,00,00,00,02,c0,14,00,ff,ff,1f,00,01,01,00,00,00,00,00,05,07,00,00,00,02,
  00,4c,00,03,00,00,00,00,00,14,00,1b,03,02,00,01,01,00,00,00,00,00,01,00,00,
  00,00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,
  00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,24,02,00,00,
  01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,01,02,00,00,00,00,00,05,20,
  00,00,00,20,02,00,00,47,00,75,00,65,00,73,00,74,00,00,00,9b,4f,65,67,be,5b,
  bf,8b,ee,95,a1,8b,97,7b,3a,67,16,62,bf,8b,ee,95,df,57,84,76,85,51,6e,7f,10,
  5e,37,62,97,7b,01,02,00,00,07,00,00,00,01,00,01,00,01,00,01,00,01,00,01,00,
  01,00,01,00

 

将它存为 guet.reg , 双击导入.这样再回我的电脑,帐户管理,就可以将guest从administrators组中删除了.

 

附个小软件:(它也没法直接删除上面碰上的情况)

Guest帐户删除大师v1.5.rar

strReverse c#中的应用

strReverse 在VB.NET中有此函数,但在C#中没有. 原文链接http://weblogs.asp.net/justin_rogers/archive/2004/06/10/153175.aspx

 

Performance: Fastest string reversing algorithms… (final results)

To start I got entries from Darren Neimke, Jerry Pisk, and Ryan Blake.  In most cases thes algorithms were the same as the ones I was going to use for demonstration, however, at the end of the competition, Darren managed to toss in one algorithm that I had overlooked because it is slow on small strings, but it actually started to pull ahead when I made some monstrous strings to test the final algorithms on.

The problem comes in three parts, allocation of a work buffer, reversing algorithm, and reintegration as a string.  That means to start we should examine the various ways that people used in order to allocate a buffer.  I’ll even show one, that turns out to be not performant at all, but you’d think it would be.

  1. string.ToCharArray – Note, this function is equivalent to net char[] + an internal memory copy.  Most users have this as the basis of their algorithm and I’ll show you why this in turn hurts perf.  In effect you are copying the data twice when you don’t need to.
  2. new char[] -This is probably the best buffer you could use.  It has no data in it yet, but strings are immutable and you’ll have the original string around the entire time as you do the reversal.
  3. StringBuilder – StringBuilder’s actually use a String behind the scenes and have the ability to convert your *work* into an instantly accessible string.  The char[] overloads for string actually have to copy your buffer into place.  This could be a solution for solving a buffer and reintegration?

Those are the three types of buffer used so far.  There could be more, but people didn’t send them in.  I’m interested in seeing a few more if anyone has them.  I experimented with memory streams and a few other ideas, but the third part of the problem, getting an actual string, always hurt other attempts.

Alrighty, so how do we reverse the string once we have it?  There are lots of answers to that depending on the buffers we used, so I’ll mention them all here.

  1. ToCharArray and Inline – This is an inline swap using the ToCharArray method.  It involves making a swap of two array locations.  This means you are going to have a single helper variable come along for the ride, since you can’t make a swap without storing a temporary local.  Because of this temporary local, these algorithms fall short a bit.  Note that as the front approaches the back, i < j, there is a point where i = j.  Most authors actually did a replacement when this occured.  However, if i = j, then you don’t need to do a replacement, and you perform in one less operation.  Any odd character in the middle of a string is already reversed 😉
  2. ToCharArray using Original – This is a modified version that uses the original string.  This actually comes out to be a bit faster, because we get rid of one copy for every 2 characters.  None of the author’s found this method, and I can’t blame them.  Why in the hell would you use the original string when you have a copy of it 😉
  3. ToCharArray using Array.Reverse – This is a surprising algorithm.  Because we get back into unmanaged code for the reversal, it actually performs better over very large strings than any of the other algorithms.  We are still making the extra copy, but in this case it doesn’t matter at all.  Darren found this one all on his own.  I wouldn’t have even tried it, because logically finding that ToCharArray was making an extra copy, I would have assumed it to still be slower (and it still is for strings less than ~100 characters).
  4. char[] using Original – This method uses a character array only.  This method gets by doing the original copy and instead saves all copying for the reversal layer.  In this scenario, you have to iterate until i <= j, because you need to restore that middle character.  This generally results in one extra unneeded replacement per run of the algorithm, but that isn’t bad.
  5. StringBuilder using Append – Slow, don’t use it.  StringBuilder is riddled with thread checks making it extremely slow.
  6. StringBuilder using initial String – Slow, don’t use it.  StringBuilder is riddled with thread checks making it extremely slow.

The surprising part is how poorly StringBuilder actually performs.  Let’s stop and think about what we are doing in the other algorithms.  We are making a copy, doing work on the buffer, then effectively making another copy to turn it back into a string.  The turning it back into a string part is actually a big operation and there isn’t anything we can do to limit it’s overhead.  Now with a StringBuilder we are making a copy that already is a now mutable string.  We can then update our buffer, and finally get a string back without incurring the extra copy.  To bad all of the bogus thread checking in there kills our performance.

Alrighty, I said three parts.  Turning the buffer back into a string is as easy as constructing a new string, or calling ToString in the case of a StringBuilder.  All there is to it, algorithms are complete.  Here they are, refactored into testable C# with the appropriate attributions to each submitter.

 

Contributor Code
Myself
Jerry Pisk
Ryan Blake
Darren Neimke
We all came up with this one. I’ve denoted both versions with the faster one being uncommented. Also note that most authors replaced the *odd* character in the middle of a string, which lost them one cycle 😉
private static string ReverseUsingCharArrayCopy(string input) {    char[] reversed = input.ToCharArray();            for(int i = 0, j = reversed.Length - 1; i < j; i++, j--) {        reversed[j] = input[i];        reversed[i] = input[j];//            char temp = reversed[i];//            reversed[i] = reversed[j];//            reversed[j] = temp;    }    return new String(reversed);}                
Darren Neimke
This method came as a surprise to me, but it actually performs faster over large strings by about 5% over the fastest algorithm. I’ll dig the rotor and find out why.
private static string ReverseUsingCharArrayCopyAndReverse(string input) {    char[] reversed = input.ToCharArray();    Array.Reverse(reversed);    return new String(reversed);}                
Me
Darren Neimke
This kicks the pants off of the ToCharArray version because we get rid of the extra copying of data. This was my original posting for fastest algorithm, and it remains so for strings less than ~100-150 characters.
private static string ReverseUsingCharArrayInline(string input) {    char[] reversed = new char[input.Length];    for(int i = 0, j = reversed.Length - 1; i <= j; i++, j--) {        reversed[i] = input[j];        reversed[j] = input[i];    }    return new String(reversed);}                
Me
I’m not a Unicode guy, so I’m not sure if my surrogate range checking code is good enough for business. Hell, I’m not really sure it works at all, I just wrote a basic algorithm that knows how to reverse items that might be composed of more than a single data block. If the algorithm I’m using here isn’t accurate, then replace the range check with an IsSurrogate check and go back to the slow days 😉
private static string ReverseUsingCharArrayInlineWithSurrogates(string input) {    char[] reversed = new char[input.Length];    for(int i = 0, j = input.Length - 1; i < input.Length; i++, j--) {        if ( input[j] >= 0xD800 && input[j] <= 0xDFFF ) {            reversed[i+1] = input[j--];            reversed[i++] = input[j];        } else {            reversed[i] = input[j];        }    }    return new String(reversed);}                
Me
One of the StringBuilder attempts. This is the fastest one and that isn’t saying much because it is still far too slow for practical usage. Every call to the indexer is invoking some threading gods, as is the call to ToString().
private static string ReverseUsingStringBuilderInline(string input) {    StringBuilder sb = new StringBuilder(input);    for(int i = 0, j = input.Length - 1; i <= j; i++, j--) {        sb[i] = input[j];        sb[j] = input[i];    }    return sb.ToString();}                

Alrighty, the above leads to some concepts for tuning our algorithm to be different based on the size of the string.  We don’t want to negatively weight our algorithm to only perform well under certain circumstances.  My recommendation would be to find a sutiable cut-off in character length for when the array reversal actually becomes faster.  In addition I propose to find out why the array reversal becomes so quick, after all, we are still copying the data one extra time in the ToCharArray call.  The slowness of the reversal is only apparent at small string lengths, and at these lengths both the original ToCharArray with swapping and the fast char[] allocation are much faster.

// Small strings
00:00:01.1816992 ToCharArray
00:00:01.4721168 ToCharArray /w Reverse
00:00:00.6609504 new char[]
00:00:00.9914256 new char[] with Surrogate Awareness
// Large strings
00:00:09.3334208 ToCharArray
00:00:07.5408432 ToCharArray /w Reverse
00:00:08.2218224 new char[]
00:00:15.1317584 new char[] with Surrogate Awareness

To note, the array reverse can never be surrogate aware, so if we wanted that feature, we couldn’t use our super fast over large strings algorithm.  Well, I think this algorithm is cooked guys.  Thanks for participating and enjoy the results.

Published Thursday, June 10, 2004 6:32 PM by Justin Rogers