zoukankan      html  css  js  c++  java
  • ADO.Net 链接 Oracle 数据库

    Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;
    Integrated Security=no;

    链接远程数据库:

     1 static void Main(string[] args)
     2  2         {
     3  3             string conStr = @"SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=IP地址)(PORT=端口号))(CONNECT_DATA=(SERVICE_NAME=监听服务)));
     4  4 uid=用户名;pwd=密码;";
     5  5             OracleConnection oracleConn = new OracleConnection(conStr);
     6  6 //oracleConn.ConnectionString =@"User Id=system;Password=123456;
     7  7 //                                     Data Source=oracleSN;";
     8  8             oracleConn.Open();
     9  9             OracleCommand cmd = new OracleCommand("select * from "UserInfo"", oracleConn);
    10 10             DataSet ds = new DataSet();
    11 11             OracleDataAdapter da = new OracleDataAdapter(cmd);
    12 12             da.Fill(ds);
    13 13 
    14 14             oracleConn.Close();
    15 15         }
    16 
    17 复制代码

     这是陈毅老师给的一个例子,链接而是远程的电脑,端口号合监听服务也是他自己设置的

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 using System.Data.OracleClient;
     8 using System.Data;
     9 
    10 
    11 namespace ConsoleApplication2
    12 {
    13     class Program
    14     {
    15         static void Main(string[] args)
    16         {
    17             string conStr = @"SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.129.119)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));
    18  uid=system;pwd=123456;";
    19             OracleConnection conn = new OracleConnection(conStr);
    20             string sql="select * from "LoginInfo"";
    21             OracleCommand cmd=new OracleCommand(sql,conn);
    22             OracleDataAdapter da = new OracleDataAdapter(cmd);
    23             DataSet ds = new DataSet();
    24             da.Fill(ds);
    25             foreach (DataRow item in ds.Tables[0].Rows)
    26             {
    27                 Console.WriteLine("ID:{0},Name:{1},pwd{2}",item["id"].ToString(),item["Name"].ToString(),item["pwd"].ToString());
    28             }
    29 
    30             Console.ReadKey();
    31         }
    32     }
    33 }
  • 相关阅读:
    CVPR-2021-Papers
    caffe中使用多个GPU的方法
    大道至简!深度解读CVPR2021论文RepVGG
    195上的rknn
    RKNN1.6下载路径
    基于深度学习的2D和3D仿射变换配准
    涵盖18+ SOTA GAN实现,开源工程StudioGAN火了
    基于opencv实战眼睛控制鼠标
    S7-200SMART PLC与变频器MODBUS RTU通讯与SMART LINE系列屏控制(案例三)
    Java异常处理学习
  • 原文地址:https://www.cnblogs.com/yaodengfeng/p/8027103.html
Copyright © 2011-2022 走看看