易截截图软件、单文件、免安装、纯绿色、仅160KB

C# 编写SQL SERVER 2005 的存储过程


以下是一个查询IP地址归属地的CLR存储过程,三步:
1、用C#来做DLL,代码如下:
//====================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
public class AddrInfo
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void getAddrInfo(SqlString ip, out SqlString info)
    {
        using (SqlConnection connection = new SqlConnection("context connection=true"))
        {
            //IP地址转为数字
            string[] tmp = ip.Value.Split(new string[]{"."},StringSplitOptions.None);
            Int64 ipn = ToInt(ToBinary(tmp[0]) + ToBinary(tmp[1]) + ToBinary(tmp[2]) + ToBinary(tmp[3]));
            connection.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = connection;
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = "select addr_info from CZIP where ipn1<="
                                + ipn.ToString() + " and ipn2>="
                            


相关文档:

SQL存储过程基础语法

一.注释
-- 单行注释,从这到本行结束为注释sql 语法,类似C++,c#中//
/* … */ 多行注释,类似C++,C#中/* … */
二.变量(int, smallint, tinyint, decimal,float,real, money ,smallmoneysql 语法, text ,image, char, varchar。。。。。。)
语法:
DECLARE
{
{@local_variable data_t ......

如何查看SQL Server 2005版本 MS2005版本 MS2000版本

要确定所运行的 SQL Server 2005 的版本,请使用 SQL Server Management Studio 连接到 SQL Server 2005,然后运行以下 Transact-SQL 语句:
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
结果:
RTM 2005.90.1399
SQL Server 2005 Service Pack 1 2005.90. ......

C#中的==,!=等符号重载,以及重载等号操作

通过一个实际的例子来介绍。其中重载==,!=,Equal,GetHashCode函数。
public class Record
{
public string[] arr = null;
public bool hasEqual = false;
//重载一个下标运算符号
public string this[int index]
{
get
{
return arr[index];
}
set
{
arr[index] = value;
}
}
public override int GetHas ......

js与c# 之间数据和方法交互

function loginNull()
{
if (document.form1.txtName.value =="")
{
//alert("请填写您的用户名!");
WebForm1.show("用户名错误,不能为空").value;
//alert("请填写您的用户名!");
document.form1.txtName.focus();
return false;
}
var filter=/^s*[.A-Za-z0-9_-]{5,15}s*$/;
if (!filter.test(document.form ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号