• 数据增删改通用 asp.net c#


    protected void Button1_Click(object sender, EventArgs e)
    {
    int res;
    string c1 = this.TextBox1.Text.ToString();
    string dw = this.DropDownList1.SelectedValue;
    string commstr = @"update data set c1='" + c1 + "'" + @"where dw='" + dw + "'";
    //"insert into data(c1) values('" + c1 + "')"


    OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|data.mdb;");
    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }
    OleDbCommand cmd = new OleDbCommand(commstr, conn);

    try
    {
    res = cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
    throw new Exception("error", ex);
    }
    finally
    {
    if (conn.State == ConnectionState.Open)
    {
    conn.Close();
    }
    }

    if (res > 0)
    {
    Response.Write("ok");
    }
    else
    {
    Response.Write("fail");
    }

    }

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    redis乐观锁
    redis
    解决创建Redis容器没有conf配置文件
    redis缓存配置
    Docker架构
    Flask获取数据的一些方法
    Nginx正向代理、反向代理与负载均衡
    Sanic
    Dockerfile详解
    Centos7上安装docker
  • 原文地址:https://www.cnblogs.com/houweidong/p/12285538.html
Copyright © 2020-2023  润新知