日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2023/12/4 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 winform插入时间类型数据到oracle数据库,winform操作访问Oracle 10g数据库,并自动填充到DataGridView... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用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...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。