ASP.NET基本的增删改查

http://blog.csdn.net/q383965374/article/details/8917269

结合公共类运用,不用公共类则可把类里的代码直接拿出来用,一样的效果

 CommonClass CC = new CommonClass();


选择数据

    string sql = "select "+str2+"  from cellardata  where cellars='" + cellar + "' and  sendtime   between'" + date1 + "'  and '" + date2 + "'";


            DataSet da=CC.GetDataSet(sql,"wendu");

删除数据

    string SqlStr1 = "delete from cellar_Info where winery_type='" + sup_id + "'";
        CC.ExecSQL(SqlStr);
更新数据
    string SqlStr = "update wineryInfo set  winery_add='" + winery_add + "', leader_name='" + leader_name + "', leader_num='" + leader_num + "', winery_name='" + winery_name + "', leader_add='" + leader_add + "', winery_remark='" + winery_remark + "'  where winery_type='" + winery_id + "'";

            CC.ExecSQL(SqlStr);
            Response.Write("<script>alert('修改成功');</script>");
新增数据

  sql1 = "insert into dbo_admin (login_name,real_name,dbo_type,winery_id,opt_pass,add_time) values('" + name.Text + "','" + realname.Text + "','" + DDL2.SelectedItem.Value + "','" + DDL3.SelectedItem.Value + "','" + passwd + "','" + DateTime.Now.ToString() + "')";
                    CC.ExecSQL(sql1);


你可能感兴趣的:(asp.net)