Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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!

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.