zoukankan      html  css  js  c++  java
  • sql2005 clr例子

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data.SqlTypes;
    using System.Text.RegularExpressions;
    using Microsoft.SqlServer.Server;
    using System.Net;
    using System.IO;
    namespace qanholas
    {
    public class net
    {
    [SqlFunction(IsDeterministic
    = true, DataAccess = DataAccessKind.None)]
    public static SqlString ping(string html)
    {
    return (SqlString)GetWebClient(html);
    }


    private static string GetWebClient(string url)
    {
    string strHTML = "";
    WebClient myWebClient
    = new WebClient();
    Stream myStream
    = myWebClient.OpenRead(url);
    StreamReader sr
    = new StreamReader(myStream, System.Text.Encoding.GetEncoding("utf-8"));
    strHTML
    = sr.ReadToEnd();
    myStream.Close();
    return strHTML;
    }



    }


    }
     
    --创建程序集 
    USE qanholas; 
    CREATE ASSEMBLY qanholas  
    FROM 'D:\WindowsApplication\qanholas\qanholas\bin\Debug\qanholas.dll' 
     
     
    --创建函数 
    CREATE FUNCTION dbo.gethtml 

        @html AS NVARCHAR(20

    RETURNS NVARCHAR(MAX
    AS 
        EXTERNAL NAME qanholas.[qanholas.net].[ping]; 
    GO 
     
     
    --无限制访问 
    USE [qanholas] 
    GO 
     
    ALTER ASSEMBLY [qanholas] 
    WITH PERMISSION_SET = UNSAFE 
     
    GO 
     
     
     
    SELECT dbo.gethtml('http:\\www.baidu.com')  
  • 相关阅读:
    如何给swing加上alt+x和ctrl+x快捷键
    java基础之登录程序
    RFID UHF(EPC)标签使用常识
    史密斯圆图
    C# DataTable Operations
    温度测量【RTD】
    温度测量【温度传感器类型】
    C# Debug
    c# ComboBox绑定枚举
    c# 隐藏Tab控件的标签
  • 原文地址:https://www.cnblogs.com/qanholas/p/2097173.html
Copyright © 2011-2022 走看看