• 完整删除


    删除

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SqlClient;
    
    namespace Delete1
    {
        class Program
        {
            static void Main(string[] args)
            {
                bool has = false;//默认has  false
                Console.Write("请输入要删除的编号:");
                string ucode = Console.ReadLine();
    
                //先查询有无此数据
                SqlConnection conn = new SqlConnection("server=.;database=Data0504;user=sa;pwd=123;");
                SqlCommand cmd = conn.CreateCommand();
    
                cmd.CommandText = "select *from Users where Ucode=@a";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@a", ucode);
    
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)//如果查到数据让has=true
                {
                    has = true;
                }
                conn.Close();
    
                if (has)//如果has=true删除成功
                {
                    //执行删除
                    Console.WriteLine("删除成功!");
                }
                else
                {
                    Console.WriteLine("未查到此编号数据,请确定编号是否正确!");
                }
    
    
    
    
    
                Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    查看tls指纹
    并行流
    方法引入2
    方法引入
    Optional.ofNullable
    stream.filter
    stream.skip limit
    反射
    Optional orElseGet
    nginx 预压缩(gzip)
  • 原文地址:https://www.cnblogs.com/skyhorseyk/p/7205878.html
Copyright © 2020-2023  润新知