vs2003连不上spl数据库

来源:百度知道 编辑:UC知道 时间:2024/05/26 20:03:56
运行以后跳转到一个页面,提示 用户“XXX”登录失败,但是在学校的机房里就没有问题

string conString = "Persist Security Info=False;Integrated Security=SSPI;database=library;server=(local)";
SqlConnection cn = new SqlConnection(conString);
cn.Open();

string selString = "select * from student_information";

SqlDataAdapter myAdapter = new SqlDataAdapter(selString,cn);
SqlCommandBuilder sqlcb = new SqlCommandBuilder(myAdapter);

DataSet myDataSet =new DataSet();
myAdapter.Fill(myDataSet,"student_information");

string s;
s = myDataSet.Tables["student_information"].Rows[0].ItemArray.ToString();

if(s!=null)
{
Response.Redirect("error.aspx");
}

Security=SSPI 是Windows集成验证,估计你们学校的是这个验证的,但你现在使用的电脑估计是混合验证的.
你可以这样定义 SqlConnection conn = new SqlConnection("server=你的服务器;database=你的数据库;uid=;pwd=");一般uid=sa;pwd=sa;但是我不知道你的电脑上装SQL的时候是用的什么密码和帐户.或者你重新注册个SQL服务器,然后身份验证用混合验证 用户名和密码都为sa然后按照我的方法就可以了.这只是介意 ,关键看你自己