使用oracle的ODP.NET是官方推荐,而且相对简单的方法。

官方指导文档:

http://www.oracle.com/technetwork/cn/testcontent/o23odp-084525-zhs.html

app.config

Form1.aspx.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Configuration;

using System.Collections;

using Oracle.DataAccess.Client;

namespace JiaJiayue

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

string connstring = ConfigurationSettings.AppSettings["ORACLE"];

//private DataGridView dataGridView1 = new DataGridView();

private BindingSource bindingSource1 = new BindingSource();

private OracleDataAdapter dataAdapter = new OracleDataAdapter();

//string connstring = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.133)(PORT=1521))(CONNECT_DATA=(SID=yy)));User Id=system;Password=orcl;";

private void btnSearch_Click(object sender, EventArgs e)

{

dataGridView1.DataSource = bindingSource1;

if (txtName.Text == "")

{

GetData("select tbm_psndoc.timecardid,psnname,deptname from tbm_psndoc left join bd_psndoc on tbm_psndoc.pk_psndoc=bd_psndoc.pk_psndoc left join bd_deptdoc on bd_psndoc.pk_deptdoc=bd_deptdoc.pk_deptdoc");

}

else

{

GetData("select tbm_psndoc.timecardid,psnname,deptname from tbm_psndoc left join bd_psndoc on tbm_psndoc.pk_psndoc=bd_psndoc.pk_psndoc left join bd_deptdoc on bd_psndoc.pk_deptdoc=bd_deptdoc.pk_deptdoc where psnname='" + txtName.Text + "'");

}

}

private void GetData(string selectCommand)

{

try

{

// Create a new data adapter based on the specified query.

dataAdapter = new OracleDataAdapter(selectCommand, connstring);

// Create a command builder to generate SQL update, insert, and

// delete commands based on selectCommand. These are used to

// update the database.

OracleCommand commandBuilder = new OracleCommand();

// Populate a new data table and bind it to the BindingSource.

DataTable table = new DataTable();

table.Locale = System.Globalization.CultureInfo.InvariantCulture;

dataAdapter.Fill(table);

bindingSource1.DataSource = table;

// Resize the DataGridView columns to fit the newly loaded content.

dataGridView1.AutoResizeColumns(

DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);

}

catch

{

}

}

private void 更新ToolStripMenuItem1_Click(object sender, EventArgs e)

{

Form2 formone = new Form2();

formone.Show();

}

}

}

winform插入时间类型数据到oracle数据库,winform操作访问Oracle 10g数据库,并自动填充到DataGridView...相关推荐

  1. python连接oracle数据库 插入clob类型数据

    python连接oracle数据库 插入clob类型数据 连接数据库 import cx_Oracle as cx #导入模块 con = cx.connect('root', 'root123', ...

  2. mysql java datetime_Java向mysql数据库插入datetime类型数据实例(精)

    在Mysql数据库中日期跟时间有两种: 1.date类型,date类型也就是我们常见的储存yyyy-MM-dd类型的日期,它不能储存时间,也就是只能储存日期, 2.dateitme就是可以储存日期同时 ...

  3. Java如何给Mysql中插入year类型数据

    文章目录 Java如何给Mysql中插入year类型数据 实际问题: 解决方案: 从数据库中读取year类型数据到Java 从Java中往数据库存储year数据 Java如何给Mysql中插入year ...

  4. 如何加载带有 AM、PM 的时间类型数据

    问题现象 时间类型数据文件中带有 AM . PM ,需要正常加载入库. 数据文件如下: pst103:/home/gbase # cat time.txt Nov 20 2016 11:30:00:1 ...

  5. JDBC向数据库中插入BLOB类型数据

    目录 1.Blob介绍 2.使用PreparedStatement向数据表中插入Blob类型字段 3.从数据表中读取Blob类型数据 4.特殊情况说明 1.Blob介绍 Blob是一种二进制数据文件, ...

  6. oracle数据库优化,访问oracle视图数据很慢

    create or replace package body PKG_ATF asprocedure GetZYWardList(s_date in varchar2, --开始时间e_date in ...

  7. mongodb 时间戳 java_Java将日期类型Date时间戳转换为MongoDB的时间类型数据

    存了一个时间类型(Date)的数据到mongo数据库中,但是前台显示的是一串数字.继而引发了如下问题: Java里面如何把 时间戳 1477387464495 转换为 2016-10-25 17:24 ...

  8. 关于时间类型数据的转换

    因为遇到后端返回得是"2019-05-24 11:42:30"这样时间类型的数据,要进行计算就不太可能所以要将他转换成时间戳计算后再转回来 话不多说上代码 timeCal(time ...

  9. 向mysql写入时间_Python向Mysql写入时间类型数据

    mysql中字段包括date和datetime两种时间类型,分别介绍如何使用Python向mysql写入上述两种时间类型的数据(主要为sql语句): 1.date类型 date = datetime. ...

最新文章

  1. excel的if函数中android,excel中if函数嵌套式使用教程
  2. python在哪里写代码比较适合-AI辅助写代码,Python之父都爱不释手的工具
  3. 【Android 异步操作】AsyncTask 异步任务 ( AsyncTask 异步任务执行方法 execute 方法相关源码解析 )
  4. TypeError: 'function' object is not subscriptable
  5. Boost:简单的双图bimap的测试程序
  6. 【转】java中定义二维数组的几种写法
  7. Android Studio 2.3的各种新增疑难杂症
  8. 前端开发学java_Java前端开发需要学习什么
  9. ROS 发布kitti数据集的gps信息
  10. Python3.WRF的投影转换
  11. STM32LCD显示汉字
  12. 博弈论总结 四大博弈模型 SG函数
  13. python体测成绩数据分析_Python+Excel数据分析实战:军事体能考核成绩评定(二)基本框架和年龄计算...
  14. 查看签名apk调试日志工具
  15. flutter 实现文字竖排以及动画效果(文字逐一显示)
  16. 学python编程从入门到实践方法-python自学Day07(自学书籍python编程从入门到实践)...
  17. 推荐5款免费好用的chatGPT平台
  18. 服务器如何几十台电脑一起装系统,多台电脑如何同时安装系统
  19. C语言将三个整数进行排序
  20. 初学Python之math模块在哪里?

热门文章

  1. VSCode+BeetleX.VueHost开发Vue应用
  2. Dapr 已在塔架就位 将发射新一代微服务
  3. IdentityServer4系列 | 快速搭建简易项目
  4. 数据结构与算法专题——第二题 优先队列
  5. 如何在Windows上使用Git创建一个可执行脚本?
  6. 走进WebApiClientCore的设计
  7. ASP.NET Core 3.x - Endpoint Routing 路由体系的内部机制
  8. Angular SPA基于Ocelot API网关与IdentityServer4的身份认证与授权(二)
  9. ASP.NET Core快速入门(第6章:ASP.NET Core MVC)--学习笔记
  10. .Net Core3.0 日志 logging