• c# 简单方便的连接oracle方式


    通过nuget安装ManagedDataAccess

    (自动生成的config里面的配置都可以删掉)

    winform程序,拖出一个datagridview和button


    using Oracle.ManagedDataAccess.Client;
    using System;
    using System.Data;
    using System.Windows.Forms;
    namespace oracle
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {

    string s = "Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 数据库ip)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)));User ID=数据库用户名;PassWord=数据库密码";

    string queryString = "select * from ztwrdata where testtime >='2016/09/13' and X<>'--' AND Y<>'--' and ROWNUM<=10";
    OracleConnection myConnection = new OracleConnection(s);
    OracleCommand myORACCommand = myConnection.CreateCommand();
    myORACCommand.CommandText = queryString;
    myConnection.Open();
    OracleDataAdapter oraDA = new OracleDataAdapter(myORACCommand);
    DataSet ds = new DataSet();
    oraDA.Fill(ds);
    DataTable dtbl = ds.Tables[0];
    dataGridView1.DataSource = dtbl;
    myConnection.Close();
    }
    }
    }

  • 相关阅读:
    windows本地提权——2003笔记
    Windows与linux添加用户命令
    反弹shell集锦
    提权-特权升级
    常见端口
    git泄露利用脚本
    Thinkphp5命令执行利用
    Thinkphp2.1漏洞利用
    打ms15-034补丁出现“此更新 不适用于您的计算机”
    Hyda爆破
  • 原文地址:https://www.cnblogs.com/hahanonym/p/5868331.html
Copyright © 2020-2023  润新知