1、在SQL Server创建 “电脑名\ASPNET”用户。比如我创建HP-2V47VI88M4GB\ASPNET
2、在SQL Enterprise manager里打开“安全性”文件夹,右击“登录”,选择“新建登录……”。“常规”选项卡,“名称”填HP-2V47VI88M4GB\ASPNET,其他默认;“数据库访问”选项卡,指定访问的数据库,我指定的是Northwind数据库,然后给他赋权限:dbo,public就够了。
Dim str As String
str = "server=.;User ID=sa;pwd="";Catalog=表名称;Data Source=数据库名称"
Dim conn As New SqlConnection(str)
conn.Open()
Dim cmd As New SqlCommand("select * from categories", conn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
DataGrid1.DataSource = dr
DataGrid1.DataBind()
conn.Close()
str = "server=.;uid=sa;pwd=;datebase=northwind"