为什么我在用visual studio建web时,我写的后台程序始终无法运行,请大大们帮我看一下,谢谢了。 10
下面是我写的一个代码:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collect...
下面是我写的一个代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = this.TextBox1.Text;
string password = this.TextBox2.Text;
string cm = this.DropList.SelectedValue;
int value1;
if (cm == "修改,添加,编辑")
{
value1 = 0;
}
else
{
value1 = 1;
}
string nect = ConfigurationSettings.AppSettings["conn"];
SqlConnection st = new SqlConnection(nect);
st.Open();
string sql = "insert into UserInfo values('" + TextBox1.Text + "','" + TextBox2 + "','value1')";
SqlCommand sqt=new SqlCommand(sql,st);
int c = sqt.ExecuteNonQuery();
st.Close();
if (c.ToString() != "0")
{
Response.Write("<script>alert('添加成功')</script>");
Response.Redirect("Default10.aspx");
}
else
Response.Redirect("Default5.aspx");
}
} 展开
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = this.TextBox1.Text;
string password = this.TextBox2.Text;
string cm = this.DropList.SelectedValue;
int value1;
if (cm == "修改,添加,编辑")
{
value1 = 0;
}
else
{
value1 = 1;
}
string nect = ConfigurationSettings.AppSettings["conn"];
SqlConnection st = new SqlConnection(nect);
st.Open();
string sql = "insert into UserInfo values('" + TextBox1.Text + "','" + TextBox2 + "','value1')";
SqlCommand sqt=new SqlCommand(sql,st);
int c = sqt.ExecuteNonQuery();
st.Close();
if (c.ToString() != "0")
{
Response.Write("<script>alert('添加成功')</script>");
Response.Redirect("Default10.aspx");
}
else
Response.Redirect("Default5.aspx");
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询