zoukankan      html  css  js  c++  java
  • C# MS Access数据库日期字段插入空值

    private void button1_Click(object sender, EventArgs e)
           {
               OleDbConnection conn = new OleDbConnection(DAL.DBConnectionString.ConnectString);
               OleDbCommand com = new OleDbCommand();
               com.Connection = conn;
               com.CommandText = "insert into aa(a,b) values(@a,@b)";
               com.Parameters.Add(new OleDbParameter("@a", "a1"));
               com.Parameters.Add(new OleDbParameter("@b", DBNull.Value));
               conn.Open();
               com.ExecuteNonQuery();        
               conn.Close();

               OleDbCommand com2 = new OleDbCommand();
               com2.Connection = conn;
               conn.Open();
               com2.CommandText = "insert into aa(a,b) values(@a,@b)";
               com2.Parameters.Add(new OleDbParameter("@a", "a2"));
               com2.Parameters.Add(new OleDbParameter("@b", Convert.ToDateTime("1992-1-1")));
               com2.ExecuteNonQuery();
               conn.Close();

               OleDbCommand com23 = new OleDbCommand();
               com23.Connection = conn;
               conn.Open();
               com23.CommandText = "insert into aa(a,b) values(@a,@b)";
               com23.Parameters.Add(new OleDbParameter("@a", "a3"));
               com23.Parameters.Add(new OleDbParameter("@b", "1993-1-1"));
               com23.ExecuteNonQuery();
               conn.Close();

               MessageBox.Show("OK");
           }

  • 相关阅读:
    java 拦截器、过滤器、监听器
    说说java
    八、 Spring Boot 过滤器、监听器
    六、Spring Boot Controller使用
    四、Spring Boot 多数据源 自动切换
    三、Spring Boot 多数据源配置
    二、spring Boot构建的Web应用中,基于MySQL数据库的几种数据库连接方式进行介绍
    对程序员面试的一些思考
    在同一个sql语句中,统计不同条件的Count数量
    redis持久化的几种方式
  • 原文地址:https://www.cnblogs.com/emanlee/p/1539442.html
Copyright © 2011-2022 走看看