求大神帮我看看为什么连接SQL数据库不成功?
我想做一个简单的登陆页面但是在类里面总是显示连接数据库不成功!类的源码:
程序代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; /// <summary> /// /// </summary> public static class db { public static SqlConnection getConn() { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "SERVER=XGG\SQL2008;UID=sa; PWD=123; DATABASE=subscriber"; conn.Open();//运行后每次都是在这报错 return conn; } public static DataSet getDataSet(string SQL) { SqlDataAdapter da = new SqlDataAdapter(SQL, getConn()); DataSet ds = new DataSet(); da.Fill(ds); return ds; } }
求大神帮忙看看!