zoukankan      html  css  js  c++  java
  • ADO.NET删除和修改

    using System.Data.SqlClient;
    
    Console.Write("请输入要删除的编号:");
    string ucode = Console.ReadLine();
    
    SqlConnection conn = new SqlConnection("server=.;database=Data0504;user=sa;pwd=123;");
    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "delete from Users where Ucode='" + ucode + "'";
    conn.Open();
    int count = cmd.ExecuteNonQuery();
    conn.Close();
    if (count > 0)
    {
    Console.WriteLine("删除成功");
    }
    else
    {
    Console.WriteLine("删除失败!");
    }
    Console.ReadLine();
    
    Console.Write("请输入您想改的内容:");
    string ucode = Console.ReadLine();
    string sql = "server=.;database=Data0504;user=sa;pwd=123";
    SqlConnection conn = new SqlConnection(sql);
    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "update Users set NickName ='" + ucode + "' where NickName='李四'";
    conn.Open();
    int count = cmd.ExecuteNonQuery();
    conn.Close();
    
    if (count > 0)
    {
    Console.WriteLine("更改成功");
    }
    else
    {
    Console.WriteLine("更改失败!");
    }
    Console.ReadLine();
  • 相关阅读:
    【转】数学题目大集合
    hdu3534,个人认为很经典的树形dp
    GYM
    HDU
    POJ
    POJ
    POJ
    set的经典应用
    天梯赛训练1 7-9 集合相似度
    天梯赛训练1 7-8 查验身份证
  • 原文地址:https://www.cnblogs.com/liuyubin0629/p/7123330.html
Copyright © 2011-2022 走看看