Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 17th, 2003, 11:03 AM
Authorized User
 
Join Date: Nov 2003
Location: , , United Kingdom.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default Returning resultset to ADO.NET dataset

I am encountering a strange problem when trying to return the results of a simple SELECT query to an ADO.NET recordset. I can do this without problems with a stored procedure, it is only when I use a "hard-coded" SELECT statement that I get issues. I need to do this because some of my SQL is dynamically generated.

Example code is as follows:-

OracleCommand oraCmd;
OracleDataAdapter oraDa;
System.Data.DataSet ds;

sql = "SELECT * FROM TBLSUBJECTS;";

oraCmd.CommandType = CommandType.Text;
oraCmd.CommandText = sql;

ds = new DataSet();
oraDa = new OracleDataAdapter(oraCmd);
oraDa.Fill(ds, scrTable);

...when the .Fill() method executes, I get the following error returned from Oracle:-

"ORA-01036: illegal variable name/number"

Can anyone tell me what I am doing wrong? Do I need to declare a RefCursor and return the results through that?

Many Thanks,
Gary
  #2 (permalink)  
Old December 19th, 2003, 01:33 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Did you instantiate the OracleCommand?
Code:
oraCmd = new OracleCommand();
or
Code:
oraCmd = new OracleCommand(sql, conn);
where conn is your connection.

--

Joe
  #3 (permalink)  
Old December 22nd, 2003, 10:28 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep ...

Your problem is the semi-colon ';' at the end of the statement. Drop this and all will be well!:)

  #4 (permalink)  
Old December 22nd, 2003, 10:44 AM
Authorized User
 
Join Date: Nov 2003
Location: , , United Kingdom.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers!



Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.NET dataset with join divinyl Crystal Reports 4 January 26th, 2006 03:12 AM
Problems With returning records through ADO marko_one Classic ASP Databases 5 September 30th, 2004 04:06 AM
ADO.NET Dataset Questions winnie1778 ADO.NET 1 October 20th, 2003 12:50 PM
ADO.NET Dataset winnie1778 Crystal Reports 0 October 17th, 2003 04:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.