C# l链接Oracle
作者:互联网
using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Oracle.ManagedDataAccess; using Oracle.ManagedDataAccess.Client; namespace OracleTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string connstring = ConfigurationManager.AppSettings["connstr"].ToString(); // MessageBox.Show(connstring); string sql = "select * from XXXX where LOTNUM=:lotnum"; //OracleParameter par = new OracleParameter(":lotnum", OracleDbType.Varchar2, 10); //par.Value = "M910262503"; OracleParameter par = new OracleParameter(":lotnum", "M910262503"); using (OracleConnection con = new OracleConnection(connstring)) { con.Open(); using (OracleCommand cmd = new OracleCommand(sql, con)) { cmd.Parameters.Add(par); using (OracleDataReader reader = cmd.ExecuteReader()) { while(reader.Read()) { string layer = reader["LAYER"].ToString(); } } } } } } }
<appSettings>
<add key="connstr" value="Password=XX;User ID=XXX;Data Source=//10.0.0.0:1521/XXX;"/>
</appSettings>
标签:par,C#,cmd,System,OracleParameter,using,Oracle,new,链接 来源: https://www.cnblogs.com/JerryZhang320/p/15754875.html