1.创建一个域用户,并且给域用户授权数据库的访问权限。
2.在asp.net网站中的webconfig,配置如下标签:
<identity impersonate="true" userName="kingwi\ConnectSQL" password="abc" />
3.设置服务器临时文件夹的访问权限 Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
将其文件夹,授权域用户的操作权限。
4.在asp.net程序中,通过如下程序方法,连接数据库
SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=demodb;Integrated Security=SSPI;");
SqlDataAdapter sda=new SqlDataAdapter("select top 10 * from 船舶日报",con);
DataSet ds=new DataSet();
sda.Fill(ds);
DataTable dt = ds.Tables[0];