110,535
社区成员
发帖
与我相关
我的任务
分享
string sql_str = "server=.;user id=sa;password='';database=pubs;";
SqlConnection conn = new SqlConnection(sql_str);
conn.Open();
conn.Close();
return true;
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace Class_server
{
public class DataAccess
{
private string ServerName = "sa";
private string ServerPwd="'123'";
public string SerName
{
get
{
return ServerName;
}
set
{
ServerName = value;
}
}
public string SerPwd
{
get { return ServerPwd; }
set { ServerPwd = value; }
}
public bool Check_Server()
{
try
{
//string sql_str = "server=.;user id=" + ServerName + ";password=" + ServerPwd + ";database=pubs;";
string sql_str = " Data Source=08F2B689112C4AF;Initial Catalog=成员管理系统;Integrated Security=True";
SqlConnection conn = new SqlConnection(sql_str);
conn.Open();
conn.Close();
return true;
}
catch
{
return false;
}
}
public SqlConnection Connect()
{
//string str = "server=.;user id =" + ServerName + ";password = " + ServerPwd + ";database = pubs";
string sql_str = " Data Source=08F2B689112C4AF;Initial Catalog=成员管理系统;Integrated Security=True";
SqlConnection sql_conn = new SqlConnection(sql_str);
return sql_conn;
}
public DataTable SelectDataBySql(string str_sql)
{
SqlConnection sql_conn = Connect();
SqlDataAdapter dscommand = new SqlDataAdapter(str_sql, sql_conn);
DataSet ds = new DataSet();
dscommand.Fill(ds);
return ds.Tables[0];
}
}
}