Connect To Oracle DB with Date Parameter

Thanks in advance;

I am attempting to return some DB records into a DataSet, with little success. My code fails repeatedly on the DateTime portion of my select string. If I comment out the date portion of the select string, the code works correctly and my DataSet will bind.
I tried changing the DateTime to a Date, and that failed. I even tried passing in a hard coded date, and that too failed. I then tried to pass in a DateTime object as a parameter, and that also failed ... ;-)
What I am doing wrong?

SelectString = null;
SelectString += "SELECT count(*) TOTALS FROM OPIS.schedule ";
SelectString += "WHERE schd_status='B' ";
SelectString += "AND rsrc in ( 'LINAC1' , 'LINAC2', 'LINAC3', 'PRIMU4', 'PRIMU5' , 'SIM' , 'CO-60' , 'HDR' , 'ORTHVO' , 'MOULD' ) ";
SelectString += "AND FROM_DATE = ? ";
//SelectString += "AND FROM_DATE = 7/30/2003 ";
//SelectString += "GROUP BY FROM_DATE, RSRC " ;
// create the OLE data adapter
System.Data.OracleClient.OracleDataAdapter myOleDbAdapter = new System.Data.OracleClient.OracleDataAdapter(SelectString, myOleDbConnection);
// add query parameters
System.Data.OracleClient.OracleParameter dateParameter = new OracleParameter("FROM_DATE", System.Data.OracleClient.OracleType.DateTime);
//dateParameter.Value = Convert.ToDateTime(DateTime.Today.ToShortDateString());
dateParameter.Value = DateTime.Today;
myOleDbAdapter.SelectCommand.Parameters.Add(dateParameter);
System.Data.DataSet returnDataSet = new System.Data.DataSet();
// open connection
myOleDbConnection.Open();
myOleDbAdapter.Fill(returnDataSet, "LastAppointment");
myOleDbConnection.Close();

And the error I get is :

System.Data.OracleClient.OracleException: ORA-01036: illegal variable name/number
at System.Data.OracleClient.OracleConnection.CheckError(OciHandle errorHandle, Int32 rc)
at System.Data.OracleClient.OracleParameterBinding.Bind(OciHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OracleClient.OracleCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)


"Never underestimate the bandwidth of a station wagon filled with backup tapes."
0
dpe94
7/31/2003 4:22:41 PM
asp.net.oracle 2269 articles. 0 followers. Follow

2 Replies
659 Views

Similar Articles

[PageSpeed] 16

I think you need quote chars around the date.


Eric McVicker
0
JOAC
8/1/2003 11:52:02 PM
Hello,

You syntax is worng, I think, you can see this example:
string selection ="select * from employees where first_name = rtrim(:firstname)";


//OracleConnect testeur = new OracleConnect ("hr","walter","walterdb");
OracleConnect testeur = new OracleConnect ((String)Session["log"],(String)Session["passe"],(String)Session["instance"]);
Titre.Text ="Les résultats de la recherche pour l'utilisateur" + Session["log"];


int i = testeur.connectiv (); // for create the Oracle connection
if (i == 1)
{
Response.Write ("la connection est bien effectué");
}
else
Response.Write (" Pb d'ouverture de la coonection ");


OracleDataAdapter mDA = new OracleDataAdapter (selection.ToString (),testeur.retourne() );

mDA.SelectCommand.Parameters.Add ("firstname",OracleType.NVarChar ,20);
mDA.SelectCommand.Parameters["firstname"].Value = NomText.Text ;

DataSet mDS = new DataSet ();
mDA.Fill (mDS,"employees");


Liste1.DataSource = mDS.Tables["employees"].DefaultView ;
Liste1.DataTextField = "last_name";
Liste1.DataBind ();
if (Liste1.SelectedIndex > -1)
{
MonDataGrid.DataSource = mDS.Tables["employees"].DefaultView ;
MonDataGrid.DataBind ();
}
else
Response.Write ("Veuillez choisir dans la liste un élément");
}
}
}
0
giniaux
8/5/2003 9:38:25 AM
Reply:

Similar Artilces:

Connect to Oracle DB in VB.NET App.
Hi All, I have a requirement of writhing VB.NET application using Oracle 8i database. I'm connecting to Oracle DB from my VB.NET Application. But I want to make my application as EXE and use in different computer withing the same network which does not has Oracle client installed. How can I do that?? Without installing Oracle client on that computer can I use my application?. If so how?? Thanks, Chamil. You could set up a webserver on the network and use WebServices for all of your database functionality. That way you could return datasets etc.. instead of or...

PB65 connect to Oracle 73 db with Oracle 8 client (native interface)
I can go as far as bringing the table list window for our Oracle 7.3 database using the Oracle 8 client (using native driver PBOR860.dll) but when I try to open any table I get "This program caused an illegal operation and will be shut down. Please contact vendor if problem persists" Details say: "Invalid page fault in module PBOR860.dll". I can reproduce this error on two other machines. I have also tried different users, including the DBA account with no luck (in the event that it was a permissions thing). Is there a problem for Powerbuilder 6.5 to connect to ...

How to connect Sql DB and Oracle DB?
Hi guys, how can i make my sql database read and store data from Oracle db?because my system reads data from sql database.. but some data need to be read from oracle and stored in sql database so the system can retrieve them from the sql database.. can anyone help me in this case? i don't know how to connect 2 different databases ... ASP.NET/VB.NET Regards,Nina@~ Why Would We Hurt Each Other, When LOVE is All We Need ~@ You create Linked Server to connect both systems, run a search for sp_linkedservers and  sp_addlinkedserver  in SQL Server BOL (books online). Hope ...

urgent: .NET Provider for Oracle or Oracle Data Provider for .NET
If I want to access Oracle DB in ASP.NET application, and I am using .NET Provider for Oracle or Oracle Data Provider for .NET, should I have to install OracleClient on my .NET server? Is there other choice? Thank you very much.Johnson Johnson2007:should I have to install OracleClient on my .NET server?  You have to options1. install the ODP.NET on your web serverOR2. put the oracle assemblies in your BIN directory   Hi jimmy,Thank you for you reply. Because I could not find a server right now, I should test it first before I agree or disagree with you, as most articles I...

Oracle as consoldated db and Oracle XE as remote db
Hi, Is it possible to use MobiLink synchronization technology with this configuration? - Oracle as consolidated database and Oracle XE as remote database; or - Oracle as consolidated database and Sybase ASA as remote database. If I'm using option 2, what software licenses do I have to buy for replication and remote databases? Thank you in advance. > Is it possible to use MobiLink synchronization technology > with this configuration? > - Oracle as consolidated database and Oracle XE as remote > database; or This configuration is not really supported at thi...

Connecting PB 5.0.03 to Oracle 8 (NT) through SQL Net v2 with driver for Oracle 7.3 of PB
Can anyone assist me on Connecting PB 5.0.03 to Oracle 8 (NT) through SQL Net v2 with driver for Oracle 7.3 of PB ? Thank you very much in advance. -- John Fotiadis Direct +30 94-464225 Senior Systems Engineer Relational Technology S.A. In article <34979B76.67A813A8@sybase.com.gr>, johnf@sybase.com.gr says... > Can anyone assist me on Connecting PB 5.0.03 to Oracle 8 (NT) through > SQL Net v2 with driver for Oracle 7.3 of PB ? > > Thank you very much in advance. > > -- > John Fotiadis > Direct +30 94-464225 > Senior Systems Enginee...

.NET Oracle Provider
Hi all,I am using .NET 2.0 Frameworks Oracle provider and it does not have a OracleDbTypes Type for me to use. I would like to create a parameter that is of the Oracle type NVARCHAR, but it seems I can only use DbTypes, which does not have this. If I used DbTypes.String, would this be ok, otherwise, how else can I be more specific about the Oracle Parameter data type?Thanks  can u explain which type of data u r going to storeThank uBaba Thank uBabaPlease remember to click "Mark as Answer" on this post if it helped you. What's your version of ODP? You have OracleD...

Connect to Oracle using Oracle Names
--27197788-12003-985187237=:188 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-Language: en-GBR Hi, I'm trying to connect to an Oracle database using Oracle Names but cannot get it to work. If I add the database to tnsnames.ora it works fine. Is Oracle Names not supported and if not will it ever be supported? Ben Schol (ben_schol@hotmail.com) --27197788-12003-985187237=:188 Content-Type: TEXT/x-cdsi-msrtf; CHARSET=US-ASCII Content-ID: 0 Content-Language: en-GBR {\rtf1\ansi\deff0{\fonttbl {\f0\fmodern\fcharset0 Courier New;}} \uc1\pard\lang1033\ulnone\f0\fs20 Hi...

OleDb.Net vs. ODBC.Net Connection to Oracle
I want to connect to an Oracle database, and I understand that I can use either the OleDB.Net data provider or the ODBC.Net data provider for my connection. Does it matter which one I use? What are the advantages and disadvantages of each? Would appreciate any input. ODBC is slower than OleDb. because ODBC has to talk to OleDbProvider then OleDbProvider will talk to Oracle Db. Instead if you are able to use OleDb straight to DB then it will be faster. If you only have THOSE choices, I would take OleDb over ODBC any day. If you are using Framework 1.1, you have the choice of using th...

How do I connect to an Oracle DB?
--=_alternative 006E62C885256CB3_= Content-Type: text/plain; charset="us-ascii" I am a neophyte Perl user, but enjoy it! I have to connect to an Oracle database and cannot make it work. (I have ordered the DBI database book by Tim Bunce) I get a message, when running my script, that says "Can't locate loadable object for module DBI in @INC (@INC contains c:/perl/lib c:/perl/site/leb ..) at c:/perl/lib DBI.pm line 243." Can anyone help me to understand what this means? Thanks, Mike Kopacki --=_alternative 006E62C885256CB3_=-- Have you loade...

oracle connectivity with .net
I just want to make the connectivity of .net with oracle database . i just want to know the steps for it and also the connection string. also one more thing, Is oracle connectivity with .net working smothly as with mssql? Please help me .  ThanksAnkur PanditM.Tech(cse)persuingIndia  If you are familier with conncting MySql with asp.net - you need no to do much.  ankurpandit:Is oracle connectivity with .net working smothly as with mssql?  Yes, its very smooth. Once you will start digging oracle - you will feel the immense power of this RDBMS.  =============...

Return an Oracle Ref Cursor to a .NET DataReader object by using the .NET Managed Provider for Oracle
Hello, I am wondering if anyone in this community knows the shorter way to return an Oracle Ref Cursor to a .NET DataReader object by using the .NET Managed Provider for Oracle, something likereturn (IDataReader) SqlHelper.ExecuteReader(ConnectionString, "GET_ACCOUNT", Id); instead of using the way below (look at the C# code) Stored Procedure create or replace PROCEDURE "GET_ACCOUNT" ( p_ID IN ACCOUNT.ID%type, retCursor OUT SA.MYGEN.sqlcur ) IS BEGIN OPEN retCursor FOR SELECT ID, NAME FROM ACCOUNT WHERE ID = p_ID ; ...

Connecting to Oracle via Oracle Instant Client
Hi, I just downloaded the Oracle instant client v 10.2. I would like to somehow use this with one of our applications that connects to Oracle. Some of our users have the Oracle client installed, most do not. I would like to be able to use this in such a way that it is distributed with the application. Our users run our applications from a shared network drive. This is where I would like to copy the OIC dlls to. If someone could give me an example of how I could use this (along with sample code of setting up and connecting using SQLCA) I would definitely appreciate it! N...

Connecting to Oracle 7.3 and Oracle 8
Hi, We've developed several PB applications that use Oracle 7.3. Now, we're moving some of the development to Oracle 8. We're trying to figure out how to set up developers' machines in the interim so that all applications will function normally. We have to decide which version of SQL*Net to use and which PB database interface for each application. Can we use different SQL*Net and interface on the same computer? So far, I can only use one version of SQL*Net during runtime (whichever one comes first in the system path). Also, during runtime, the PB database interface...

Web resources about - Connect To Oracle DB with Date Parameter - asp.net.oracle

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google Webmaster Tools Parameter Handling - Flickr - Photo Sharing!
You aren't signed in Sign In Help Home The Tour Sign Up Explore Explore Home Last 7 Days Interesting Popular Tags Calendar Most Recent Uploads ...

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 11/23/2015 7:45:33 PM