主题:求高手指教
[color=800000]SqlConn.Open(); 这块代码出现异常 [[/color]ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。
数据库名肯定没错,请教高手如何解决
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
///conn 的摘要说明
/// </summary>
public class conn
{
private static string connection = "Provider=SQLOLEDB;Data Source=DFSDFG-LP0WH4KC\\SQLEXPRESS;uid=sa;pwd=181818;Database=ExamOnline;";
public OleDbConnection SqlConn = new OleDbConnection(connection);
public conn()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public void DBopen()
{
if (SqlConn.State == ConnectionState.Closed)
{
SqlConn.Open();
}
}
public void DBclose()
{
if (SqlConn.State == ConnectionState.Open)
{
SqlConn.Close();
}
}
数据库名肯定没错,请教高手如何解决
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
///conn 的摘要说明
/// </summary>
public class conn
{
private static string connection = "Provider=SQLOLEDB;Data Source=DFSDFG-LP0WH4KC\\SQLEXPRESS;uid=sa;pwd=181818;Database=ExamOnline;";
public OleDbConnection SqlConn = new OleDbConnection(connection);
public conn()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public void DBopen()
{
if (SqlConn.State == ConnectionState.Closed)
{
SqlConn.Open();
}
}
public void DBclose()
{
if (SqlConn.State == ConnectionState.Open)
{
SqlConn.Close();
}
}