 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics 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
|
|
|
|

September 9th, 2007, 10:17 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Urgent: Oralce Stored Procedure
Hi,
I never used stored procedures in asp.net and can anyone give example how to create stored procedure in oracle to display users table in grdiview.
Any help highly appreciated.
I wrote something like this, and its giving errors in sql plus.
create or replace PROCEDURE sp_users (out types.cursor)
AS
CURSOR c1 IS
SELECT * FROM Users
;
rs c1%ROWTYPE;
BEGIN
END;
__________________
Rams
|
|

September 10th, 2007, 05:55 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You can simply create like below:
CREATE OR REPLACE PROCEDURE sp_users
IS
BEGIN
SELECT * FROM Users;
END;
Regards
Mike
===================================
To the world you might be one person,
but for someone you may be the whole world.
===================================
^^Though the above is non-technical, but there is no harm thinking emotionally.
|
|

September 14th, 2007, 12:27 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Mike.. Thank you very much. It works. Now i am stuck with following problem when iam using this with Where statement.
I passed one parameter in that procedure sp_users (sUserFilter as VARCHAR2(64))
In my asp.net code, earlier i was using sql query like this.
sSQL = "SELECT * FROM Users WHERE CreatedOn = to_date('1/1/2007','mm/dd/yyyy') "
If sUserFilter <> "" Then sSQL &= " AND UserID LIKE '%" & sUserFilter & "%'"
Now in stored procedure, how can i write above query, if parameter is null and parameter is not null ?
Any help is great.
Thanks
|
|

September 17th, 2007, 03:51 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You need to use the Oledb class to access the oracle data, try something like below:
string queryString = "SELECT * FROM Table1 WHERE Field1 LIKE ?";
OleDbCommand command = new OleDbCommand(queryString, connection);
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a";
OleDbDataReader reader = command.ExecuteReader();
Regards
Mike
|
|

September 17th, 2007, 02:17 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, will this query works even if i don't want to pass parameter? because parameter is not required field.
|
|

September 18th, 2007, 09:55 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If parameter is not required, do not pass it. I have just given you an example, so modify the sql string accordingly.
Regards
Mike
|
|

September 18th, 2007, 10:06 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks.
parameter is required field only when user click on search filter. Do we need to create 2 stored procedures for 2 conditions (with parameter and no parameter)? OR Do we need to change sql query inside sp, if yes how can we?
|
|
 |