• oracle 测试代码


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Globalization;
    using System.Runtime.InteropServices;
    using Oracle.DataAccess;


    namespace testjpcn
    {
      
        public partial class Form1 : Form
        {
            [DllImport("kernel32.dll", SetLastError = true)]
            static extern int GetThreadLocale();
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                Oracle.DataAccess.Client.OracleConnection ocn = new Oracle.DataAccess.Client.OracleConnection();
                ocn.ConnectionString = "User Id=System;Password =oracle;Data Source=ujpcn";
                ocn.Open();
                Oracle.DataAccess.Client.OracleCommand ocmd = new Oracle.DataAccess.Client.OracleCommand();
                ocmd.CommandText = "INSERT INTO TEST (ID,MEMO) VALUES('" + System.DateTime.Now.ToLongTimeString() + "','" + textBox1.Text+"')";
                 
                ocmd.Connection = ocn;
                ocmd.ExecuteNonQuery();

                Oracle.DataAccess.Client.OracleDataAdapter odp = new Oracle.DataAccess.Client.OracleDataAdapter();
                DataSet ds = new DataSet();
                Oracle.DataAccess.Client.OracleCommand ocmd1 = new Oracle.DataAccess.Client.OracleCommand();
                ocmd1.CommandText = "select * from test";
                ocmd1.Connection = ocn;
                odp.SelectCommand = ocmd1;
                odp.Fill(ds);
                this.dataGridView1.DataSource = ds.Tables[0];
            
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                CultureInfo cInfo = CultureInfo.GetCultureInfo(GetThreadLocale());
                this.label2.Text = cInfo.CompareInfo.Name.ToString();

                Oracle.DataAccess.Client.OracleConnection ocn = new Oracle.DataAccess.Client.OracleConnection();
                ocn.ConnectionString = "User Id=System;Password =oracle;Data Source=ujpcn";
                ocn.Open();
                Oracle.DataAccess.Client.OracleCommand ocmd= new Oracle.DataAccess.Client.OracleCommand();
                ocmd.CommandText = "select * from test";
                ocmd.Connection = ocn;
                Oracle.DataAccess.Client.OracleDataAdapter odp = new Oracle.DataAccess.Client.OracleDataAdapter();
                
                DataSet ds = new DataSet();
                odp.SelectCommand = ocmd;
     
                odp.Fill(ds);
                this.dataGridView1.DataSource = ds.Tables[0]; 
               
               
            }
        }
    }

  • 相关阅读:
    Hibernate——openSession和getCurrentSession区别
    Oracle存储过程分页 详解
    如何破解mysql数据库的密码
    Oracle约束详解
    Oracle分页查询
    Oracle如何管理权限和角色
    悲观锁和乐观锁详解
    Oracle控制结构详解
    Rose建模之各模型分析
    div布局中将页面居中的方法
  • 原文地址:https://www.cnblogs.com/Alvin/p/1624008.html
Copyright © 2020-2023  润新知