MessageBox.Show不能用要加什么类啊,提示找不到类型或命名空间名称 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 添了可是提示说windows在类或命名空间system中不存在啊 MessageBox在forms里啊,不可能没有,除非你的framework坏了 帖一下你的代码和错误信息吧。这几乎是不可能的,除非framework真的是坏了。 using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Text;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.Windows.Forms;——————————————???namespace WebApplication1{ /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class add_User : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Label Label2; protected System.Web.UI.WebControls.Label Label3; protected System.Web.UI.WebControls.Label Label4; protected System.Web.UI.WebControls.Label Label5; protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.TextBox TextBox3; protected System.Web.UI.WebControls.TextBox TextBox4; protected System.Web.UI.WebControls.TextBox TextBox5; protected System.Web.UI.WebControls.Label Label6; protected System.Web.UI.WebControls.TextBox Textbox6; protected System.Web.UI.WebControls.Button Button1; private void Page_Load(object sender, System.EventArgs e) { } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { //Server.Transfer("add_User_save.aspx"); String insertCmd="insert into users(UserID,UserName,Password,DepartmentID) values(@UserID,@UserName,@Password,@DepartmentID)"; if ( TextBox1.Text!= "" && TextBox2.Text!= "" &&TextBox3.Text != "" && TextBox4.Text != "") { SqlConnection myConnection=new SqlConnection("server=(local);uid=sa;pwd=012345;database=sw"); SqlCommand myCommand =new SqlCommand(insertCmd,myConnection); myCommand.Parameters.Add(new SqlParameter("@UserID",SqlDbType.Decimal,9)); myCommand.Parameters["@UserID"].Value=TextBox1.Text; myCommand.Parameters.Add(new SqlParameter("@UserName",SqlDbType.Char,30)); myCommand.Parameters["@UserName"].Value=TextBox2.Text; myCommand.Parameters.Add(new SqlParameter("@Password",SqlDbType.Char,30)); myCommand.Parameters["@Password"].Value=TextBox3.Text; myCommand.Parameters.Add(new SqlParameter("@DepartmentID",SqlDbType.Decimal,9)); myCommand.Parameters["@DepartmentID"].Value=TextBox4.Text; myCommand.Connection.Open(); myCommand.ExecuteNonQuery(); //Message.Text="<b>Add Successfully </b>"+insertCmd; myCommand.Connection.Close(); } else { System.MessageBox.Show ( "必须填满所有字段值!" , "错误!" ) ; } } }} 晕~~asp里面不使用这个,用的是javascriptAlert(""); MessageBox是在WinForm里面使用的,在WebForm里并不适用,使用Javascript的Alert吧 汗,原来是ASP.NET的,呵呵,楼上说了,用javascript吧。 关于数据库合并的问题,请指点一二! 在pictureBox1 上添加文字 高手请进 写函数什么遇到异常情况但又不想立即处理是抛出异常还是返回一个有意义的值 VS2008使用问题 在Winform中如何限定TextBox,只让用户写入数字,而不能录入字符 winform中sidebar控件如何使用 写SQL语句的问题,怎么判断字段里的日期是否为今天? dgv如何隐藏单元格的值 急!高手帮忙!如何通过编程把word文档(或者把剪贴板上的内容)转化为bmp位图? Windows 2003 Server建邮件服务器 错误提示Application.Exit();的using是什么? 求各位指点。
可是提示说windows在类或命名空间system中不存在啊
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text;
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.Windows.Forms;——————————————???
namespace WebApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class add_User : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox Textbox6;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e) {
//Server.Transfer("add_User_save.aspx");
String insertCmd="insert into users(UserID,UserName,Password,DepartmentID) values(@UserID,@UserName,@Password,@DepartmentID)";
if ( TextBox1.Text!= "" && TextBox2.Text!= "" &&TextBox3.Text != "" && TextBox4.Text != "")
{
SqlConnection myConnection=new SqlConnection("server=(local);uid=sa;pwd=012345;database=sw");
SqlCommand myCommand =new SqlCommand(insertCmd,myConnection);
myCommand.Parameters.Add(new SqlParameter("@UserID",SqlDbType.Decimal,9));
myCommand.Parameters["@UserID"].Value=TextBox1.Text;
myCommand.Parameters.Add(new SqlParameter("@UserName",SqlDbType.Char,30));
myCommand.Parameters["@UserName"].Value=TextBox2.Text;
myCommand.Parameters.Add(new SqlParameter("@Password",SqlDbType.Char,30));
myCommand.Parameters["@Password"].Value=TextBox3.Text;
myCommand.Parameters.Add(new SqlParameter("@DepartmentID",SqlDbType.Decimal,9));
myCommand.Parameters["@DepartmentID"].Value=TextBox4.Text;
myCommand.Connection.Open(); myCommand.ExecuteNonQuery();
//Message.Text="<b>Add Successfully </b>"+insertCmd; myCommand.Connection.Close();
}
else
{
System.MessageBox.Show ( "必须填满所有字段值!" , "错误!" ) ;
}
}
}
}
Alert("");