zoukankan      html  css  js  c++  java
  • ado添加

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Data.SqlClient;
    
    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {
                //添加数据
                //1、获取用户输入信息
                Console.Write("请输入学生编号:");
                string scode = Console.ReadLine();
    
                Console.Write("请输入学生姓名:");
                string sname = Console.ReadLine();
    
                Console.Write("请输入学生性别:");
                bool ssex =Convert.ToBoolean( Console.ReadLine());
    
                Console.Write("请输入学生生日:");
                DateTime sbirthday =Convert.ToDateTime( Console.ReadLine());
    
                Console.Write("请输入学生分数:");
                decimal sscore = Convert.ToDecimal( Console.ReadLine());
    
    
                //2、开启数据库连接,添加用户输入信息
                SqlConnection conn = new SqlConnection("server=.;database=data0425;user=sa;pwd=123;");
    
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "insert into student values('" + scode + "','" + sname + "','" + ssex + "','" + sbirthday + "'," + sscore + ")";
                //cmd.CommandText = "insert into Student values('" + scode + "','" + sname + "','" + ssex + "','" + sbirthday + "'," + sscore + ")";
                //Console.WriteLine(cmd.CommandText);
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    Console.WriteLine("添加成功!");
                }
                catch
                {
                    Console.WriteLine("连接数据库失败!请重新连接输入!");
                }
    
                conn.Close();
    
                
    
    
    
    
    
    
                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    unable to retrieve container logs for docker kubernetes
    Restart container within pod
    Kubernetes1.3:POD生命周期管理
    Options of the DB storage of prometheus
    prometheus重启hang住问题记录
    prometheus交流资源
    nc 从服务器上传下载文件
    负载均衡监控需求
    prometheus消耗内存问题
    10.Docker 镜像使用
  • 原文地址:https://www.cnblogs.com/fengsantianya/p/5604591.html
Copyright © 2011-2022 走看看