请教一个连接sql server2000数据库的问题
jonry 2005-08-29 01:33:35 我在vs.net用下面的程序连接sql server2000数据库,但总是报错“用户 'WIT\ASPNET' 登录失败”。请各位高手多多指教。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace MyWebApp
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection dbConnection;
SqlDataAdapter dbAdapter;
dbConnection=new SqlConnection(@"Data Source=(local);Integrated security=SSPI;Initial Catalog=test");
SqlCommand command=new SqlCommand();
command.CommandText="select * from userinfo";
command.Connection=dbConnection;
dbAdapter=new SqlDataAdapter();
dbAdapter.SelectCommand=command;
DataSet data=new DataSet();
dbAdapter.Fill(data);
DataGrid1.DataSource=data;
DataGrid1.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}