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();
}
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询