div弹出层的ajax登录(Jquery版+c#)(3)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for Common
/// </summary>
public class Common
{
public Common()
{
//
// TODO: Add constructor logic here
//
}

/// <summary>
/// 加载SQL服务列表
/// </summary>
/// <returns></returns>
public static IList<string> GetServers()
{
IList<string> list = new List<string>();
SqlDataSourceEnumerator sse = SqlClientFactory.Instance.CreateDataSourceEnumerator() as SqlDataSourceEnumerator;
if (sse == null) return null;
DataTable dt = sse.GetDataSources();
foreach (DataRow dr in dt.Rows)
{
string server = dr["ServerName"] as string;
string instance = dr["InstanceName"] as string;
if (string.IsNullOrEmpty(instance) || instance.ToUpper() == "MSSQLSERVER")
list.Add(server);
else
list.Add(server + @"https://www.jb51.net/article/\" + instance);
}
return list;
}

/// <summary>
/// SQL Server Authentication
/// </summary>
/// <param>SQL服务</param>
/// <param>用户名</param>
/// <param>密码</param>
/// <param>数据库连接字符串</param>
/// <returns></returns>
public static bool IsLogin(string server,string user,string password,out string sqlConstring)
{
sqlConstring = string.Format("Data Source={0};Initial Catalog=master;Persist Security Info=True;User ID={1};Password={2}", server, user, password);
return SQLHelper.LoginSQL(sqlConstring);
}
}



SQLHelper.cs

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjdszg.html