急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 应该是SqlDataReader,第一个字母大写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼上的很对using System.Data.sqlClient;这个sqlClient也应该是 SqlClient你要注意一下大小写 楼上的都对,如果不喜欢大小写区分,就学VB.NET吧 多谢各位!现在又有一个问题:程序编译能通过,当我用鼠标点击按扭是出现提示:(是建立.aspx项目的)用户 'LARRY_WANG\ASPNET' 登录失败。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 用户 'LARRY_WANG\ASPNET' 登录失败。源错误: 行 177: {行 178: String sele1 = "SELECT * FROM table1";行 179: sqlConnection1.Open();行 180: sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1); 行 181: SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader(); 源文件: c:\inetpub\wwwroot\datalink1\dataprogram.aspx.cs 行: 179 堆栈跟踪: [SqlException: 用户 'LARRY_WANG\ASPNET' 登录失败。] System.Data.SqlClient.SqlConnection.Open() dataLink1.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\datalink1\dataprogram.aspx.cs:179 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain() +1263 太长了!贴不下!分两叶吧using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Data.SqlClient;namespace dataLink1{ /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlCommand sqlInsertCommand1; protected System.Data.SqlClient.SqlConnection sqlConnection1; protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; protected dataLink1.books books1; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected System.Web.UI.WebControls.Button Button1; private DataTable table; private DataColumn col; protected System.Web.UI.WebControls.Button Button2; protected System.Web.UI.WebControls.Button Button3; protected System.Web.UI.WebControls.Button Button4; private DataRow row; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 try { table = new DataTable(); } catch { } try { col = new DataColumn (); col.DataType = System.Type.GetType("system.string"); col.ColumnName = "书名"; col.AutoIncrement = false; col.Unique = false; col.ReadOnly =false; table.Columns .Add (col); col = new DataColumn (); col.DataType = System.Type.GetType("system.string"); col.ColumnName = "作者"; col.AutoIncrement = false; col.Unique = false; col.ReadOnly = false; table.Columns.Add(col); col = new DataColumn (); col.DataType = System.Type.GetType("system.string"); col.ColumnName = "责任者"; col.AutoIncrement = false; col.Unique = false; col.ReadOnly = false; table.Columns.Add(col); col = new DataColumn (); col.DataType = System.Type.GetType("system.double"); col.ColumnName = "定价"; col.AutoIncrement = false; col.Unique = false; col.ReadOnly = false; table.Columns.Add(col); DataGrid1.DataSource = table; DataGrid1.DataBind(); } catch { } } private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e) { } private void Button1_Click(object sender, System.EventArgs e) { String sele1 = "SELECT * FROM table1"; sqlConnection1.Open(); sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1); SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader(); while(reader1.Read()) { row = table.NewRow(); row["书名"] = reader1.GetString(1); row["作者"] = reader1.GetString(2); row["责任人"] = reader1.GetString(4); row["定价"] = reader1.GetString(6); table.Rows.Add(row); } reader1.Close(); DataGrid1.DataSource = table; DataGrid1.DataBind (); } private void Button2_Click(object sender, System.EventArgs e) { String insert = "INSERT INTO Table1VALUES()"; books1.AcceptChanges(); sqlConnection1.Open (); sqlInsertCommand1 = new SqlCommand(insert,sqlConnection1); sqlInsertCommand1.ExecuteNonQuery (); sqlConnection1.Close(); sqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Table1"; sqlDataAdapter1.Fill(books1.Table1); DataGrid1.DataSource = books1.Table1 ; DataGrid1.DataBind(); } private void Button3_Click(object sender, System.EventArgs e) { String deleteCommand = "DELETE * FROM Table1 WHERE ISBN = 00001"; books1.AcceptChanges (); sqlConnection1.Open (); SqlCommand sqlDeleteCommand1 = new SqlCommand(deleteCommand,sqlConnection1); sqlDeleteCommand1.ExecuteNonQuery (); sqlConnection1.Close (); sqlDataAdapter1.SelectCommand .CommandText = "SELETE * FROM Table1"; sqlDataAdapter1.Fill(books1.Table1); DataGrid1.DataSource = books1.Table1 ; DataGrid1.DataBind(); } private void Button4_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(books1.Table1); DataGrid1.DataSource = books1.Table1; DataGrid1.DataBind (); } }} 就是用c#来操作sqlserver数据库!的例题 {String sele1 = "SELECT * FROM table1";sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1); (1)sqlConnection1.Open();(2)SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader();1,2反了 SqlConnection sqlConnection1=new SqlConnection("ConnectionString");ConnectionString中的数据库连接字符串有错。你的程序中我没看见这句话,可能你打掉了. “/dataLink1”应用程序中的服务器错误。--------------------------------------------------------------------------------配置错误 说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。 分析器错误信息: 访问被拒绝:“dataLink1”。源错误: 行 170: <add assembly="System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>行 171: <add assembly="System.EnterpriseServices, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>行 172: <add assembly="*"/>行 173: </assemblies>行 174: 源文件: c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config 行: 172 --------------------------------------------------------------------------------版本信息: Microsoft .NET 框架版本:1.0.3705.0; ASP.NET 版本:1.0.3705.0 这又是什么问题?编译没问题,编译完后叶面上就是这样了! 本人水平太底,麻烦你手把手的教教我,thanks! 关于委托,抛的“参数计数不匹配”异常,又来求助大家了! 时间的一个判断 怎么根据树型table递归建立treeview结点 winform 一个通用窗体如何给根据传来的值控制多个父窗体? 浮点数存储一定要转换成字符串再存储吗? 怎样在.NET中操纵Exhcange活动目录?? 急....在线等..转换问题 请高手帮忙把一个加密函数改写为c#,万分感谢!!!!! 微信中的php代码改成C#的 请问大家关于网页安全的问题 web应用中访问映射盘上的文件? 关于C#中的命名法!
using System.Data.sqlClient;这个sqlClient也应该是 SqlClient你要注意一下大小写
(是建立.aspx项目的)
用户 'LARRY_WANG\ASPNET' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 用户 'LARRY_WANG\ASPNET' 登录失败。源错误:
行 177: {
行 178: String sele1 = "SELECT * FROM table1";
行 179: sqlConnection1.Open();
行 180: sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1);
行 181: SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader();
源文件: c:\inetpub\wwwroot\datalink1\dataprogram.aspx.cs 行: 179 堆栈跟踪:
[SqlException: 用户 'LARRY_WANG\ASPNET' 登录失败。]
System.Data.SqlClient.SqlConnection.Open()
dataLink1.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\datalink1\dataprogram.aspx.cs:179
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1263
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;namespace dataLink1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected dataLink1.books books1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Button Button1; private DataTable table;
private DataColumn col;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
private DataRow row;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
try
{
table = new DataTable();
}
catch
{
} try
{
col = new DataColumn ();
col.DataType = System.Type.GetType("system.string");
col.ColumnName = "书名";
col.AutoIncrement = false;
col.Unique = false;
col.ReadOnly =false;
table.Columns .Add (col);
col = new DataColumn ();
col.DataType = System.Type.GetType("system.string");
col.ColumnName = "作者";
col.AutoIncrement = false;
col.Unique = false;
col.ReadOnly = false;
table.Columns.Add(col);
col = new DataColumn ();
col.DataType = System.Type.GetType("system.string");
col.ColumnName = "责任者";
col.AutoIncrement = false;
col.Unique = false;
col.ReadOnly = false;
table.Columns.Add(col);
col = new DataColumn ();
col.DataType = System.Type.GetType("system.double");
col.ColumnName = "定价";
col.AutoIncrement = false;
col.Unique = false;
col.ReadOnly = false;
table.Columns.Add(col); DataGrid1.DataSource = table;
DataGrid1.DataBind();
}
catch
{
}
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
} private void Button1_Click(object sender, System.EventArgs e)
{
String sele1 = "SELECT * FROM table1";
sqlConnection1.Open();
sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1);
SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader();
while(reader1.Read())
{
row = table.NewRow();
row["书名"] = reader1.GetString(1);
row["作者"] = reader1.GetString(2);
row["责任人"] = reader1.GetString(4);
row["定价"] = reader1.GetString(6);
table.Rows.Add(row);
}
reader1.Close();
DataGrid1.DataSource = table;
DataGrid1.DataBind ();
} private void Button2_Click(object sender, System.EventArgs e)
{
String insert = "INSERT INTO Table1VALUES()";
books1.AcceptChanges();
sqlConnection1.Open ();
sqlInsertCommand1 = new SqlCommand(insert,sqlConnection1);
sqlInsertCommand1.ExecuteNonQuery ();
sqlConnection1.Close();
sqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Table1";
sqlDataAdapter1.Fill(books1.Table1); DataGrid1.DataSource = books1.Table1 ;
DataGrid1.DataBind();
} private void Button3_Click(object sender, System.EventArgs e)
{
String deleteCommand = "DELETE * FROM Table1 WHERE ISBN = 00001";
books1.AcceptChanges ();
sqlConnection1.Open ();
SqlCommand sqlDeleteCommand1 = new SqlCommand(deleteCommand,sqlConnection1);
sqlDeleteCommand1.ExecuteNonQuery ();
sqlConnection1.Close ();
sqlDataAdapter1.SelectCommand .CommandText = "SELETE * FROM Table1";
sqlDataAdapter1.Fill(books1.Table1); DataGrid1.DataSource = books1.Table1 ;
DataGrid1.DataBind();
} private void Button4_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(books1.Table1);
DataGrid1.DataSource = books1.Table1;
DataGrid1.DataBind ();
}
}
}
String sele1 = "SELECT * FROM table1";
sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1); (1)
sqlConnection1.Open();(2)
SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader();
1,2反了
--------------------------------------------------------------------------------配置错误
说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。 分析器错误信息: 访问被拒绝:“dataLink1”。源错误:
行 170: <add assembly="System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
行 171: <add assembly="System.EnterpriseServices, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
行 172: <add assembly="*"/>
行 173: </assemblies>
行 174:
源文件: c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config 行: 172
--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.0; ASP.NET 版本:1.0.3705.0 这又是什么问题?编译没问题,编译完后叶面上就是这样了!