从vb.net中的oracle连接并检索数据 [英] Connect and retrive data from oracle in vb.net

查看:65
本文介绍了从vb.net中的oracle连接并检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vb.net中开发了一个应用程序,oracle作为大学项目的后端..

我想连接从oracle访问数据并在vb.net中使用它。

请帮助我..

请发送一些100%工作的示例项目或示例代码。

我在这方面不太好。

如此友好地说一步一步的程序



我尝试了什么:



Dim oradb As String =Data Source = orcl; User Id = hr; Password = hr;

Dim conn As New OracleConnection(oradb)

conn .Open()

Dim cmd作为新的OracleCommand

cmd.Connection = conn

cmd.CommandText =从department_id =部门选择department_name 10

cmd.CommandType = CommandType.Text

Dim dr As OracleDataReader = cmd.ExecuteReader()

dr.Read()

Label1.Text = dr.Item(department_name)

conn.Dispose()



我试过这个..它没有显示任何错误河但是数据没有重新获得

解决方案

阅读本文 -

FreeVBCode代码片段:使用VB.NET在Oracle中连接和检索数据 [ ^ ]


为了与oracle连接,首先需要的是ODP(oracle数据提供商)下载它,之后添加对以下程序集的引用

 Oracle.DataAccess.dll。

其余代码似乎没问题。



有关详细说明,请查看以下链接 - > 通过以下方式连接到Oracle数据库C#? - Stack Overflow [ ^ ]


I have devolping an application in vb.net, oracle as backend for college project..
I want connect to access data from oracle and use it in vb.net.
Please help me..
kindly send some sample project or sample code that works 100%.
I am not too good in this.
So kindly say step by step procedure

What I have tried:

Dim oradb As String = "Data Source=orcl;User Id=hr;Password=hr;"
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "select department_name from departments where department_id = 10"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dr.Read()
Label1.Text = dr.Item("department_name")
conn.Dispose()

I tried this.. It does not show any error. but the data doesnot retrived

解决方案

Read this -
FreeVBCode code snippet: Connect and Retrieve Data in Oracle With VB.NET[^]


For connection with the oracle first thing you need is the ODP(oracle data provider) download it and after that add reference to the following assembly

Oracle.DataAccess.dll.

rest of your code seems to be ok.

For detailed explanation please check on the following link-->Connecting to Oracle Database through C#? - Stack Overflow[^]


这篇关于从vb.net中的oracle连接并检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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