| | |
C# calling parameterized Oracle storage procedure ?
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jul 2006
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I'm trying to call a parameterized stored procedure in C# using microsoft ODBC .NET. Could you please give me some help or hint? Thank you very much!
C# code:
... //connection code
odbcCommand.CommandType = CommandType.StoredProcedure;
odbcCommand.CommandText = "BEGIN myProc(?, ?); END;";
odbcCommand.CommandTimeout = 0;
OdbcParameter paramA =
odbcCommand.Parameters.Add("@A_CNT", OdbcType.Int);
paramA.Value = _a_cnt;
OdbcParameter paramB =
odbcCommand.Parameters.Add("@B_CNT", OdbcType.Int);
paramB.Value = _b_cnt;
try
{
odbcCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.Error.WriteLine(DateTime.Now.ToString()
+ ex.Message);
throw ex;
}
The SP itself looks like:
CREATE OR REPLACE PROCEDURE myProc (
A_CNT IN BINARY_INTEGER,
B_CNT IN BINARY_INTEGER) AS
BEGIN
NULL;
COMMIT;
END;
It's simplified. I tried to directly use
odbcCommand.CommandText = "BEGIN myProc(1, 2); END;";
And that works! However, unfortunately I actually need to use the two variables _a_cnt and _b_cnt as input arguments for the SP. Then I got following error message which complains about the question mark in "BEGIN myProc(?, ?); END;"
ERROR [HY000]
[Oracle][ODBC][Ora]ORA-06550: line 1, column 14
LS-00103: Encountered the symbol
"" when expecting one of the following: ( ) - + case mod new not null others
<an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
merge year month DAY_ hour minute second timezone_hour
timezone_minute timezone_region timezone_abbr time timestamp
interval date
<a
The suspicious symbol in the error message is a question mark upside down.
Oracle 10g release 2.
I'm trying to call a parameterized stored procedure in C# using microsoft ODBC .NET. Could you please give me some help or hint? Thank you very much!
C# code:
... //connection code
odbcCommand.CommandType = CommandType.StoredProcedure;
odbcCommand.CommandText = "BEGIN myProc(?, ?); END;";
odbcCommand.CommandTimeout = 0;
OdbcParameter paramA =
odbcCommand.Parameters.Add("@A_CNT", OdbcType.Int);
paramA.Value = _a_cnt;
OdbcParameter paramB =
odbcCommand.Parameters.Add("@B_CNT", OdbcType.Int);
paramB.Value = _b_cnt;
try
{
odbcCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.Error.WriteLine(DateTime.Now.ToString()
+ ex.Message);
throw ex;
}
The SP itself looks like:
CREATE OR REPLACE PROCEDURE myProc (
A_CNT IN BINARY_INTEGER,
B_CNT IN BINARY_INTEGER) AS
BEGIN
NULL;
COMMIT;
END;
It's simplified. I tried to directly use
odbcCommand.CommandText = "BEGIN myProc(1, 2); END;";
And that works! However, unfortunately I actually need to use the two variables _a_cnt and _b_cnt as input arguments for the SP. Then I got following error message which complains about the question mark in "BEGIN myProc(?, ?); END;"
ERROR [HY000]
[Oracle][ODBC][Ora]ORA-06550: line 1, column 14
LS-00103: Encountered the symbol"" when expecting one of the following: ( ) - + case mod new not null others
<an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
merge year month DAY_ hour minute second timezone_hour
timezone_minute timezone_region timezone_abbr time timestamp
interval date
<a
The suspicious symbol in the error message is a question mark upside down.
Oracle 10g release 2.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- This is a wierd one! (Windows NT / 2000 / XP)
- arrays and randomize (Pascal and Delphi)
- Passing a structure into an Oracle Procedure (ColdFusion)
- High Water Mark. (Oracle)
- Problem with the keyboard hooks (C#)
- Help Needed (Oracle)
- Calling Oracle Stored Procedures with ASP (ASP)
Other Threads in the C# Forum
- Previous Thread: Table Layout Pannels
- Next Thread: Return in comboBox
| Thread Tools | Search this Thread |
.net access algorithm animation array bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees directrobot dll draganddrop drawing encryption enum excel file filename files form format formbox forms function gdi+ gis gtk hash image input install java label list mandelbrot math mouseclick mp3 mysql native operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml





