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();

  • 相关阅读:
    JVM系列三:JVM参数设置、分析
    JVM系列二:GC策略&内存申请、对象衰老
    HotSpot VM GC 的种类
    2.静态库和动态库
    1.GCC编译过程
    6.树
    5.队列
    4.栈
    3.线性表
    2.算法
  • 原文地址:https://www.cnblogs.com/yujiamin123/p/7114840.html
Copyright © 2011-2022 走看看