职位关键字 工作地点
工作名称 公司名称 校园招聘
中国最好的工作搜索引擎!
  回复留言  
  关于asp.net 用VB连接sql server数据库(100分)在线等
作者: 夜色_正浓  01-01 08:00   回复  
 我用的是 VB.NET2003的版本



做一个最简单的数据库连接 只用了DataGrid 控件显示 数据库中的信息



我在Button 写入下面代码:

Dim str As String

str = "server=.;integrated security=sspi ;initial catalog=northwind"

Dim conn As New SqlConnection(str)

Dim cmd As New SqlCommand("select * from categories", conn)

conn.Open()

Dim dr As SqlDataReader = cmd.ExecuteReader()

DataGrid1.DataSource = dr

DataGrid1.DataBind()

conn.Close()



--------

连接的数据库中已有的数据的一张表

用浏览器查看会出现以下错误,本人想知道怎样才可以运行不出错,我数据库用的是系统默认登陆的 考试要用 谢谢了

如果谁能解决并且给出删除 添加等代码,不胜感谢 肯定给高分



以下是出错信息///









用户 'B843F473D8A24DA\ASPNET' 登录失败。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。



异常详细信息: System.Data.SqlClient.SqlException: 用户 'B843F473D8A24DA\ASPNET' 登录失败。



源错误:





行 36: Dim conn As New SqlConnection(str)

行 37: Dim cmd As New SqlCommand("select * from categories", conn)

行 38: conn.Open()

行 39: Dim dr As SqlDataReader = cmd.ExecuteReader()

行 40: DataGrid1.DataSource = dr





源文件: c:\inetpub\wwwroot\haohaod\WebForm1.aspx.vb 行: 38



堆栈跟踪:





[SqlException: 用户 'B843F473D8A24DA\ASPNET' 登录失败。]

System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472

System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372

System.Data.SqlClient.SqlConnection.Open() +384

haohaod.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\haohaod\WebForm1.aspx.vb:38

System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain() +1277

  回复:关于asp.net 用VB连接sql server数据库(100分)在线等
作者: meteoroid1984  01-01 08:00   回复  
 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()

  回复:关于asp.net 用VB连接sql server数据库(100分)在线等
作者: 清影漂泊  06-14 12:15   回复  
  str = "server=.;uid=sa;pwd=;datebase=northwind"

  回复:关于asp.net 用VB连接sql server数据库(100分)在线等
作者: wangyuii  06-14 12:15   回复  
  1、在SQL Server创建 “电脑名\ASPNET”用户。比如我创建HP-2V47VI88M4GB\ASPNET

2、在SQL Enterprise manager里打开“安全性”文件夹,右击“登录”,选择“新建登录……”。“常规”选项卡,“名称”填HP-2V47VI88M4GB\ASPNET,其他默认;“数据库访问”选项卡,指定访问的数据库,我指定的是Northwind数据库,然后给他赋权限:dbo,public就够了。

标 题:
内 容:
用户名:
 游客
 
 
Copyright©2005-2007, 版权所有 WWW.JOBMET.COM
ICP证:京ICP备06019556号