[英]Connect to Oracle Database in C#
I want to test Oracle Database in my C# windows application. 我想在C#Windows应用程序中测试Oracle数据库。 I have created a workspace on Oracle Application Express.
我已经在Oracle Application Express上创建了一个工作区。 I have also created DNS and the connection is formed successfully.
我还创建了DNS,并且连接成功建立。
On successful connection I have written a code to get the list of tables. 成功连接后,我编写了代码以获取表列表。
schemaTable = connection.GetSchema("Tables");
This code snippet successfully returns the list the tables. 此代码段成功返回了列表列表。 Now when I try to read the data from EMP table I receive below error:
现在,当我尝试从EMP表读取数据时,出现以下错误:
ERROR [42S02] [Oracle][ODBC][Ora]ORA-00903: invalid table name
错误[42S02] [Oracle] [ODBC] [Ora] ORA-00903:无效的表名
Query to retrieve the data from EMP table 查询以从EMP表中检索数据
queryString: "Select * from [EMP];" queryString:“从[EMP]中选择*;”
using (OdbcConnection connection = new OdbcConnection(connString))
{
try
{
connection.Open();
OdbcDataAdapter da = new OdbcDataAdapter(queryString, connection);
da.Fill(fillGridDt);
I figured out the solution. 我想出了解决方案。 It was throwing the error invalid table name as i was using [] brackets with table name.
由于我使用带表名的[]括号,因此抛出了错误的表名错误。 ie Select * from [EMP] I tried the query with Select * from EMP;
即从[EMP]中选择*我尝试了从EMP中选择*的查询; and now it works
现在可以了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.