Click here to Skip to main content
15,900,254 members
Home / Discussions / C#
   

C#

 
Generalaccessing listbox items on a form from another class Pin
mr spoon14-Sep-04 10:20
mr spoon14-Sep-04 10:20 
GeneralRe: accessing listbox items on a form from another class Pin
Heath Stewart14-Sep-04 11:45
protectorHeath Stewart14-Sep-04 11:45 
GeneralRe: accessing listbox items on a form from another class Pin
mr spoon15-Sep-04 10:23
mr spoon15-Sep-04 10:23 
GeneralStored Procedures with C# Pin
Member 131560014-Sep-04 9:47
Member 131560014-Sep-04 9:47 
GeneralRe: Stored Procedures with C# Pin
Steve Maier14-Sep-04 10:42
professionalSteve Maier14-Sep-04 10:42 
GeneralRe: Stored Procedures with C# Pin
Heath Stewart14-Sep-04 11:20
protectorHeath Stewart14-Sep-04 11:20 
GeneralRe: Stored Procedures with C# Pin
Steve Maier14-Sep-04 15:25
professionalSteve Maier14-Sep-04 15:25 
GeneralRe: Stored Procedures with C# Pin
Heath Stewart14-Sep-04 11:29
protectorHeath Stewart14-Sep-04 11:29 
You use stored procs pretty much the same way as you do with SQL Server, just that the named parameters are identified a little differently (common with different RDBMS's). From the .NET Framework SDK documentation for the OracleCommand.CommandType property:
When the CommandType property is set to StoredProcedure, you should set the CommandText property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, ExecuteReader or ExecuteNonQuery).

The Connection, CommandType and CommandText properties cannot be set if the current connection is performing an execute or fetch operation.

The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an OracleCommand of CommandType.Text. In this case, named parameters must be used. For example:

SELECT * FROM Customers WHERE CustomerID = :pCustomerID

When using named parameters in an SQL statement or stored procedure, you must precede the parameter name with a colon (Smile | :) . However, when referring to a named parameter elsewhere in your code (for example, when calling Add), do not precede the named parameter with a colon (Smile | :) . The .NET Framework Data Provider for Oracle supplies the colon automatically.
The same should also be true if you use an Oracle connection string using the System.Data.OleDb namespace classes. To note, the Oracle ADO.NET driver is provided in .NET 1.1 but was only a beta release for .NET 1.0 and, IIRC, is not officially supported (but works). You can use System.Data.OleDb classes for compatibility if you feel you must, but you would be wise to use .NET 1.1 anyway, as many, many performance enhancements and bug fixes were made to the codebase.

So, as an example:
OracleConnection conn = new OracleConnection("...");
OracleCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "myproc(:param1, :param2)";
cmd.Parameters.Add("param1", OracleType.Int32).Value = 1;
cmd.Parameters.Add("param2", OracleType.Char, 40).Value = "CodeProject");
using (conn)
{
  conn.Open();
  cmd.ExecuteNonQuery();
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralDatgrid Record Count Pin
thewilddba14-Sep-04 9:25
thewilddba14-Sep-04 9:25 
GeneralRe: Datgrid Record Count Pin
Angel Reyes14-Sep-04 9:44
Angel Reyes14-Sep-04 9:44 
GeneralRe: Datgrid Record Count Pin
sreejith ss nair14-Sep-04 18:09
sreejith ss nair14-Sep-04 18:09 
Generalscroll bar i the listview control Pin
bora3ee14-Sep-04 8:36
bora3ee14-Sep-04 8:36 
GeneralRe: scroll bar i the listview control Pin
Dave Kreskowiak14-Sep-04 9:51
mveDave Kreskowiak14-Sep-04 9:51 
Generalzip libraries Pin
elena1234514-Sep-04 8:14
elena1234514-Sep-04 8:14 
GeneralRe: zip libraries Pin
Gary Thom14-Sep-04 10:07
Gary Thom14-Sep-04 10:07 
GeneralRe: zip libraries Pin
Steve Maier14-Sep-04 10:44
professionalSteve Maier14-Sep-04 10:44 
GeneralRe: zip libraries Pin
Heath Stewart14-Sep-04 11:17
protectorHeath Stewart14-Sep-04 11:17 
GeneralRe: zip libraries Pin
suthan14-Sep-04 19:50
suthan14-Sep-04 19:50 
GeneralRe: zip libraries Pin
leppie15-Sep-04 6:07
leppie15-Sep-04 6:07 
GeneralWeb Page Comments Pin
Gary Hyslop at home14-Sep-04 7:48
Gary Hyslop at home14-Sep-04 7:48 
GeneralRe: Web Page Comments Pin
Dave Kreskowiak14-Sep-04 10:07
mveDave Kreskowiak14-Sep-04 10:07 
GeneralRe: Web Page Comments Pin
Heath Stewart14-Sep-04 11:05
protectorHeath Stewart14-Sep-04 11:05 
GeneralBitmap Dispose Pin
ee9903514-Sep-04 7:33
ee9903514-Sep-04 7:33 
GeneralRe: Bitmap Dispose Pin
Dave Kreskowiak14-Sep-04 9:03
mveDave Kreskowiak14-Sep-04 9:03 
GeneralRe: Bitmap Dispose Pin
Tom Larsen14-Sep-04 11:56
Tom Larsen14-Sep-04 11:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.