zoukankan      html  css  js  c++  java
  • 微软自己写的~测试远程数据库是否工作正常

     1 <%@ Page Language="C#" %>
     2 
     3 <%@ Import Namespace="System.Data.SqlClient" %>
     4 <%        
     5     string ServerName = "测试";
     6     string DBIP = "-"; // - 表示没有数据库服务器
     7     string DBName = "";
     8     string DBUser = "";
     9     string DBPassword = "";
    10     string conn = string.Format(@"Data Source={0};Initial Catalog={1};Persist Security Info=True;
    11                          User Instance=False;User ID={2};Password={3};MultipleActiveResultSets=true"
    12        , DBIP
    13        , DBName
    14        , DBUser
    15        , DBPassword);
    16 
    17 
    18     string message = "NoSql";
    19     if (DBIP != "-")
    20     {
    21         using (SqlConnection _conn = new SqlConnection(conn))
    22         {
    23             using (SqlCommand comm = new SqlCommand("SELECT COUNT(1)  FROM sys.tables", _conn))
    24             {
    25                 try
    26                 {
    27                     _conn.Open();
    28                     comm.ExecuteReader();
    29                     message = "OK";
    30                     _conn.Close();
    31                     _conn.Dispose();
    32                 }
    33                 catch (Exception)
    34                 {
    35                     message = "Fail";
    36                 }
    37 
    38             }
    39         }
    40     }
    41 
    42 
    43     string callback = Request["jsonpcallback"];
    44     Response.ContentType = "application/x-javascript";
    45     string str = callback + "({" + string.Format("\'ServerName\':\'{0}\', \'ServerIP\':\'{1}\',\'IISMessage\':\'{2}\',\'DBMessage\':\'{3}\'", ServerName, Request.ServerVariables["LOCAL_ADDR"].ToString(), "OK", message) + "})";
    46     Response.Write(str);
  • 相关阅读:
    Pytest框架之命令行参数2
    Pytest框架之命令行参数1
    [编程题] 二维数组中的查找
    [编程题]二叉树镜像
    补充基础:栈与队列模型
    6641. 【GDOI20205.20模拟】Sequence
    瞎讲:任意模数MTT
    瞎讲:FFT三次变二次优化
    小米oj 重拍数组求最大和
    小米oj 有多少个公差为2的等差数列
  • 原文地址:https://www.cnblogs.com/lori/p/2731701.html
Copyright © 2011-2022 走看看