asp.net update语句
protectedvoidButton3_Click(objectsender,EventArgse){stringstrConnection="Provider=Mic...
protected void Button3_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=D:\WebSite2\App_Data\kaoqin.mdb";
OleDbConnection conn = new OleDbConnection(strConnection);
conn.Open();
string sql = "update student set s_password='" + this.TextBox6.Text + "' where s_name= '" + this.TextBox1.Text + "'" ;
我接下来的代码有错,下面我想实现对数据库的修改,还有提示修改成功,和修改失败的提示,请哪位高手帮忙补全下。 展开
{
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=D:\WebSite2\App_Data\kaoqin.mdb";
OleDbConnection conn = new OleDbConnection(strConnection);
conn.Open();
string sql = "update student set s_password='" + this.TextBox6.Text + "' where s_name= '" + this.TextBox1.Text + "'" ;
我接下来的代码有错,下面我想实现对数据库的修改,还有提示修改成功,和修改失败的提示,请哪位高手帮忙补全下。 展开
2个回答
展开全部
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=D:\WebSite2\App_Data\kaoqin.mdb";
conn.Open();
try
{
string sql = "update student set s_password='" + this.TextBox6.Text + "' where s_name= '" + this.TextBox1.Text + "'" ;
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('成功!')</script>");//这里写成功的语句
}
catch
{
Response.Write("<script>alert('失败!')</script>");//提示错误
}
finally
{
conn.Closed();
}
strConnection += @"Data Source=D:\WebSite2\App_Data\kaoqin.mdb";
conn.Open();
try
{
string sql = "update student set s_password='" + this.TextBox6.Text + "' where s_name= '" + this.TextBox1.Text + "'" ;
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('成功!')</script>");//这里写成功的语句
}
catch
{
Response.Write("<script>alert('失败!')</script>");//提示错误
}
finally
{
conn.Closed();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询