ADO.Net对oracle数据库操作的实例代码
时间:2024-01-18 02:00:41
首先要写连接字符串
可以在web.config里写上
<connectionStrings>
<add name="oracleson" connectionString="Data Source=dingsenorcl;Persist Security Info=True;User ID=ds;Password=ds;Unicode=True" providerName="System.Data.OracleClient"/>
</connectionStrings>
<connectionStrings>
<add name="oracleson" connectionString="Data Source=dingsenorcl;Persist Security Info=True;User ID=ds;Password=ds;Unicode=True" providerName="System.Data.OracleClient"/>
</connectionStrings>
然后再后台调用
string orclcon = ConfigurationManager.ConnectionStrings["oracleson"].ConnectionString;
string orclcon = ConfigurationManager.ConnectionStrings["oracleson"].ConnectionString;
然后要新建一个数据库连接对象
OracleConnection conn = new OracleConnection(orclcon)
OracleConnection conn = new OracleConnection(orclcon)
创建一个OracleCommand对象来对数据库进行操作
OracleCommand cmd = conn.CreateCommand()
OracleCommand cmd = conn.CreateCommand()打开连接
conn.Open();操作就行了
cmd.CommandText = "insert into T_12(AAAA)values(:a)";
cmd.Parameters.AddWithValue(":a", TextBox1.Text); //参数替换oracle数据库要用: sqlserver数据库是@
cmd.ExecuteNonQuery();
cmd.CommandText = "insert into T_12(AAAA)values(:a)";
cmd.Parameters.AddWithValue(":a", TextBox1.Text); //参数替换oracle数据库要用: sqlserver数据库是@
cmd.ExecuteNonQuery();
标签:.Net,oracle,操作
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python采用raw_input读取输入值的方法
2021-09-08 03:19:05
python使用yield压平嵌套字典的超简单方法
2023-08-28 03:20:00
![](https://img.aspxhome.com/file/2023/0/93670_0s.jpg)
vue.js编译时给生成的文件增加版本号
2024-05-10 14:18:15
python使用py2neo创建neo4j的节点和关系
2021-09-25 01:03:28
![](https://img.aspxhome.com/file/2023/1/71391_0s.png)
pandas pd.read_csv()函数中parse_dates()参数的用法说明
2023-07-22 04:51:26
![](https://img.aspxhome.com/file/2023/8/63978_0s.jpg)
Go语言每天必学之switch语句
2024-04-26 17:33:59
![](https://img.aspxhome.com/file/2023/5/133975_0s.jpg)
Tensorflow 查看变量的值方法
2022-12-14 09:36:47
几款好用的前端开发编辑器推荐安利
2023-11-21 13:30:00
![](https://img.aspxhome.com/file/2023/6/71296_0s.png)
浅析vue-router原理
2023-07-02 17:09:19
![](https://img.aspxhome.com/file/2023/5/139955_0s.png)
Python+OpenCV实现图像融合的原理及代码
2022-08-01 00:03:52
![](https://img.aspxhome.com/file/2023/9/101239_0s.jpg)
python中yaml配置文件模块的使用详解
2021-06-05 08:06:45
Python装饰器实现方法及应用场景详解
2022-04-30 22:57:49
python3.0 字典key排序
2022-06-03 15:07:50
Python 注解方式实现缓存数据详解
2023-07-15 22:11:22
说说如何遍历Python列表的方法示例
2023-05-26 14:01:52
![](https://img.aspxhome.com/file/2023/6/112606_0s.png)
Python画图时如何调用本地字体
2023-08-02 08:51:31
![](https://img.aspxhome.com/file/2023/6/61486_0s.png)
JavaScript获取echart曲线上任意点位的值详解
2024-05-02 16:57:52
![](https://img.aspxhome.com/file/2023/8/130148_0s.png)
如何更改 pandas dataframe 中两列的位置
2023-01-06 03:14:23
![](https://img.aspxhome.com/file/2023/3/97083_0s.jpg)
[译]Javascript风格要素(二)
2008-02-29 12:51:00
常用SQL语句词典
2008-08-03 17:19:00