急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

larrybest 2003-07-28 01:36:32
我在写数据库操作程序时,已经写了using System.Data.sqlClient;
可编译时老是提示:c:\inetpub\wwwroot\dataLink1\DataProgram.aspx.cs(190): 找不到类型或命名空间名称“sqlDataReader”(是否缺少 using 指令或程序集引用?)
...全文
29 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiangyangsunboy1 2003-07-28
  • 打赏
  • 举报
回复
好哇!!!!!!!!!!!
larrybest 2003-07-28
  • 打赏
  • 举报
回复
本人水平太底,麻烦你手把手的教教我,thanks!
xiangyangsunboy1 2003-07-28
  • 打赏
  • 举报
回复
我知道
Knight94 2003-07-28
  • 打赏
  • 举报
回复
修改数据库连接,不要用本地信任连接,要用数据库自身的用户名和密码来连接。
larrybest 2003-07-28
  • 打赏
  • 举报
回复
“/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



这又是什么问题?编译没问题,编译完后叶面上就是这样了!
MarcuseXiao 2003-07-28
  • 打赏
  • 举报
回复
SqlConnection sqlConnection1=new SqlConnection("ConnectionString");

ConnectionString中的数据库连接字符串有错。

你的程序中我没看见这句话,可能你打掉了.
sakuoya 2003-07-28
  • 打赏
  • 举报
回复
{
String sele1 = "SELECT * FROM table1";
sqlSelectCommand1 = new SqlCommand(sele1,sqlConnection1); (1)
sqlConnection1.Open();(2)
SqlDataReader reader1 = sqlSelectCommand1.ExecuteReader();
1,2反了
larrybest 2003-07-28
  • 打赏
  • 举报
回复
就是用c#来操作sqlserver数据库!的例题
larrybest 2003-07-28
  • 打赏
  • 举报
回复

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 ();
}
}
}
larrybest 2003-07-28
  • 打赏
  • 举报
回复
太长了!贴不下!分两叶吧
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
{
}




}
qimini 2003-07-28
  • 打赏
  • 举报
回复
把你的连接字符串贴出来
qimini 2003-07-28
  • 打赏
  • 举报
回复
把你的连接字符串贴出来
larrybest 2003-07-28
  • 打赏
  • 举报
回复
多谢各位!现在又有一个问题:

程序编译能通过,当我用鼠标点击按扭是出现提示:
(是建立.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


MarcuseXiao 2003-07-28
  • 打赏
  • 举报
回复
楼上的都对,如果不喜欢大小写区分,就学VB.NET吧
remyxu 2003-07-28
  • 打赏
  • 举报
回复
使用带C的,就要看大小写!
就是么,不要这样夸张!!!!!
panyee 2003-07-28
  • 打赏
  • 举报
回复
楼上的很对
using System.Data.sqlClient;

这个sqlClient也应该是 SqlClient

你要注意一下大小写
Knight94 2003-07-28
  • 打赏
  • 举报
回复
应该是SqlDataReader,第一个字母大写

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧