一、忘记sqlserver密码时,运行语句,可修改密码,记得查看账户是否被禁用
EXECUTE sp_password NULL,‘输入新密码‘,‘sa‘;
二、代码:data source一定要加上sqlexpress
SqlConnection conn = new SqlConnection("server=localhost;Data Source=.\\SQLEXPRESS;database=doc;user=sa;password=123456");
try
{
conn.Open();
}
catch (Exception e)
{
Console.WriteLine("数据库未连接成功{0}", e.Message);
}
finally
{
conn.Close();
}
Console.ReadKey();
}
时间: 2024-10-05 23:27:39