如何从C#Windows应用程序将数据插入到Oracle中 [英] How to insert data into oracle from C# windows application

查看:47
本文介绍了如何从C#Windows应用程序将数据插入到Oracle中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
如何从C#Windows应用程序将数据插入到oracle的表中

Hello,
How to insert data into tables of oracle from C# windows application

推荐答案

C#:无需安装Oracle客户端即可连接到Oracle数据库(Winform DataGridView加载示例)

在没有tnsnames.ora的情况下从C#/Winforms/Asp.net连接到Oracle

带有Oracle数据库的C#.Net
C#: Connect To Oracle Database With No Oracle Client Install Needed (Winform DataGridView Loading Example)

Connecting to Oracle from C# / Winforms / Asp.net without tnsnames.ora

C#.Net with oracle database



检查此
使用C#在Oracle中插入CLOB数据 [ ^ ]
http://docs.oracle.com/html/B10961_01/client21.htm [ ^ ]
https://forums.oracle.com/forums/thread.jspa?threadID=471177 [ ^ ]
最好的问候
M.Mitwalli
Hi ,
Check this
Using C# for Inserting CLOB Data in Oracle[^]
http://docs.oracle.com/html/B10961_01/client21.htm[^]
https://forums.oracle.com/forums/thread.jspa?threadID=471177[^]
Best Regards
M.Mitwalli


尝试一下:

在Public Class声明之前添加以下C#using语句.
Try this:

Add the following C# using statements before the Public Class declaration.
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
using Oracle.DataAccess.Types;




之间添加以下C#代码



Add the following C# code in between the

private void button1_Click(object sender, EventArgs e)


{和}语句.


{ and } statements.

string oradb = "Data Source=ORCL;User Id=hr;Password=hr;";

OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into Table1('Name') VALUES(txtName.text) WHERE id = 1"; 
Int rowsUpdated = cmd.ExecuteNonQuery(); 
If (rowsUpdated == 0) 
 MessageBox.Show("Record not inserted"); 
Else 
 MessageBox.Show("Success!"); 
conn.Dispose();



希望对您有所帮助!



Hope it helps!


这篇关于如何从C#Windows应用程序将数据插入到Oracle中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆