童言无忌,不懂就问...........数据库.....

ziluolan 2004-01-18 09:56:58
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;

namespace index
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button topost;
protected System.Web.UI.WebControls.TextBox userpwd;
protected System.Web.UI.WebControls.TextBox username;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlCommand1;

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sqlConn=new SqlConnection ("server=soft.;database=employee;userid=sa;password=123;");

SqlCommand sqlComm=new SqlCommand("select * from productnews ",sqlConn);

//String aa=username.Text;

//this.Response.Write( SqlCommand );

//this.Response.End();

sqlConn.Open();
SqlDataReader dr=sqlComm.ExcuteReader();
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.topost.Click += new System.EventHandler(this.topost_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion




private void topost_Click(object sender, System.EventArgs e)
{

}
}
}
希望朋友们,帮我改改哦
...全文
33 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gucs 2004-01-18
  • 打赏
  • 举报
回复
建议你先说,自己要做什么,遇到了什么样的问题,然后把你觉得可能引发问题的代码帖出来,如果大家仍然不能解决问题,再帖出全部代码也不迟
shenanigan 2004-01-18
  • 打赏
  • 举报
回复
先添加一个名称空间:
using System.Data.SqlClient;
ziluolan 2004-01-18
  • 打赏
  • 举报
回复
仍然有错误
错误提示如下:

e:\news\index\index.aspx.cs(29,4): error CS0246: 找不到类型或命名空间名称“SqlConnection”(是否缺少 using 指令或程序集引用?)
e:\news\index\index.aspx.cs(31,4): error CS0246: 找不到类型或命名空间名称“SqlCommand”(是否缺少 using 指令或程序集引用?)
e:\news\index\index.aspx.cs(34,4): error CS0246: 找不到类型或命名空间名称“sqlConn”(是否缺少 using 指令或程序集引用?)
e:\news\index\index.aspx.cs(35,4): error CS0246: 找不到类型或命名空间名称“SqlDataReader”(是否缺少 using 指令或程序集引用?)
zhoumingxuan 2004-01-18
  • 打赏
  • 举报
回复
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;

namespace index
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button topost;
protected System.Web.UI.WebControls.TextBox userpwd;
protected System.Web.UI.WebControls.TextBox username;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlCommand1;

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sqlConn=new SqlConnection ("server=soft.;database=employee;userid=sa;password=123;");

SqlCommand sqlComm=new SqlCommand("select * from productnews ",sqlConn);

//String aa=username.Text;

//this.Response.Write( SqlCommand );

//this.Response.End();

sqlConn.Open();
SqlDataReader dr=sqlComm.ExcuteReader();
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.topost.Click += new System.EventHandler(this.topost_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
private void topost_Click(object sender, System.EventArgs e)
{

}


已经改好了,拷贝回去就可以用了
shenanigan 2004-01-18
  • 打赏
  • 举报
回复
错误信息呢?
shenanigan 2004-01-18
  • 打赏
  • 举报
回复
先添加一个名称空间:
using System.Data.SqlClient;
ziluolan 2004-01-18
  • 打赏
  • 举报
回复
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;

namespace index
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button topost;
protected System.Web.UI.WebControls.TextBox userpwd;
protected System.Web.UI.WebControls.TextBox username;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlCommand1;

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sqlConn=new SqlConnection ("server=soft.;database=employee;userid=sa;password=123;");

SqlCommand sqlComm=new SqlCommand("select * from productnews ",sqlConn);

//String aa=username.Text;

//this.Response.Write( SqlCommand );

//this.Response.End();

sqlConn.Open();
SqlDataReader dr=sqlComm.ExcuteReader();
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.topost.Click += new System.EventHandler(this.topost_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
private void topost_Click(object sender, System.EventArgs e)
{

}


ziluolan 2004-01-18
  • 打赏
  • 举报
回复
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;

namespace index
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button topost;
protected System.Web.UI.WebControls.TextBox userpwd;
protected System.Web.UI.WebControls.TextBox username;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlCommand1;

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sqlConn=new SqlConnection ("server=soft.;database=employee;userid=sa;password=123;");

SqlCommand sqlComm=new SqlCommand("select * from productnews ",sqlConn);

//String aa=username.Text;

//this.Response.Write( SqlCommand );

//this.Response.End();

sqlConn.Open();
SqlDataReader dr=sqlComm.ExcuteReader();
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.topost.Click += new System.EventHandler(this.topost_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
private void topost_Click(object sender, System.EventArgs e)
{

}
}

110,535

社区成员

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

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

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