Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you
are all aware that accessing a property is expensive than calling a method.
For example in order to call a stored procedure which accepts 2 input
parameters, we are currently following the below standard to set a single
parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter ();
objOracleParameterSTATUS.ParameterName ="STATUS_IN";
objOracleParameterSTATUS.SourceColumn = "STATUS"
objOracleParameterSTATUS.OracleType=System.Data.Or acleClient.OracleType.Number;
objOracleParameterSTATUS.Size =1;
objOracleParameterSTATUS.Precision =0;
objOracleParameterSTATUS.Scale =0;
objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input;
objOracleParameterSTATUS.SourceVersion=System.Data .DataRowVersion.Current;
objOracleParameterSTATUS.Value =STATUS;
bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if
this stored procedure accepts 10 parameters, then this process has to be
repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the
above code or how can I make this less expensive and efficient.
Thanks for your help!!! 6 1899
If that object has no method to set all of them, then there is nothing you
can do.
I honestly don't think you are going to see an actual performance problem by
having to set 9 properties instead of calling 1 method.
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com... Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you are all aware that accessing a property is expensive than calling a method. For example in order to call a stored procedure which accepts 2 input parameters, we are currently following the below standard to set a single parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); objOracleParameterSTATUS.ParameterName ="STATUS_IN"; objOracleParameterSTATUS.SourceColumn = "STATUS"; objOracleParameterSTATUS.OracleType=System.Data.Or acleClient.OracleType.Number; objOracleParameterSTATUS.Size =1; objOracleParameterSTATUS.Precision =0; objOracleParameterSTATUS.Scale =0; objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; objOracleParameterSTATUS.SourceVersion=System.Data .DataRowVersion.Current; objOracleParameterSTATUS.Value =STATUS; bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if this stored procedure accepts 10 parameters, then this process has to be repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the above code or how can I make this less expensive and efficient.
Thanks for your help!!!
Property getters and setters are generally short enough to be inlined
by the optimizing compiler, so they won't be as expensive as a method
call. No need to worry....
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 13 May 2005 12:41:11 -0700, Diffident
<Di*******@discussions.microsoft.com> wrote: Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you are all aware that accessing a property is expensive than calling a method. For example in order to call a stored procedure which accepts 2 input parameters, we are currently following the below standard to set a single parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); objOracleParameterSTATUS.ParameterName ="STATUS_IN"; objOracleParameterSTATUS.SourceColumn = "STATUS"; objOracleParameterSTATUS.OracleType=System.Data.O racleClient.OracleType.Number; objOracleParameterSTATUS.Size =1; objOracleParameterSTATUS.Precision =0; objOracleParameterSTATUS.Scale =0; objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; objOracleParameterSTATUS.SourceVersion=System.Dat a.DataRowVersion.Current; objOracleParameterSTATUS.Value =STATUS; bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if this stored procedure accepts 10 parameters, then this process has to be repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the above code or how can I make this less expensive and efficient.
Thanks for your help!!!
Instead of coding these many lines for each and every parameter, is there
anyway that I can reduce the lines of code ? How can I design a resusable
method for setting these properties......so that this method can be called
for each and every parameter?
"Scott Allen" wrote: Property getters and setters are generally short enough to be inlined by the optimizing compiler, so they won't be as expensive as a method call. No need to worry....
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 13 May 2005 12:41:11 -0700, Diffident <Di*******@discussions.microsoft.com> wrote:
Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you are all aware that accessing a property is expensive than calling a method. For example in order to call a stored procedure which accepts 2 input parameters, we are currently following the below standard to set a single parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); objOracleParameterSTATUS.ParameterName ="STATUS_IN"; objOracleParameterSTATUS.SourceColumn = "STATUS"; objOracleParameterSTATUS.OracleType=System.Data.O racleClient.OracleType.Number; objOracleParameterSTATUS.Size =1; objOracleParameterSTATUS.Precision =0; objOracleParameterSTATUS.Scale =0; objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; objOracleParameterSTATUS.SourceVersion=System.Dat a.DataRowVersion.Current; objOracleParameterSTATUS.Value =STATUS; bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if this stored procedure accepts 10 parameters, then this process has to be repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the above code or how can I make this less expensive and efficient.
Thanks for your help!!!
Hi,
actually I do not know the OracleClient - but I am sure, the Oracle Provider
provides an overloaded constructor for the OracleParameter Object (this is
available for the SQL-Server Client at last).
This is the way, I solve this for a SQL-Server sp parameter:
(Please note: the SqlParameter has 6 different constructors. One of them can
handle all the properties you are using - like
Direction,Scale,Precision,Size, etc)
myCommand.Parameters.Add(New SqlClient.SqlParameter("@PKClientGuid",
SqlDbType.UniqueIdentifier)).Value = Client.Guid
I think this is much more read- and maintainable.
Hope I could help you!
Regards,
Tom
"Diffident" <Di*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:9C**********************************@microsof t.com... Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you are all aware that accessing a property is expensive than calling a method. For example in order to call a stored procedure which accepts 2 input parameters, we are currently following the below standard to set a single parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); objOracleParameterSTATUS.ParameterName ="STATUS_IN"; objOracleParameterSTATUS.SourceColumn = "STATUS"; objOracleParameterSTATUS.OracleType=System.Data.Or acleClient.OracleType.Number; objOracleParameterSTATUS.Size =1; objOracleParameterSTATUS.Precision =0; objOracleParameterSTATUS.Scale =0; objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; objOracleParameterSTATUS.SourceVersion=System.Data .DataRowVersion.Current; objOracleParameterSTATUS.Value =STATUS; bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if this stored procedure accepts 10 parameters, then this process has to be repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the above code or how can I make this less expensive and efficient.
Thanks for your help!!!
Boilerplate data access code such as this can be dramatically simplified by
using Microsoft's free Data Access Application Block.
Here's more info: http://aspnet.4guysfromrolla.com/articles/070203-1.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Diffident" <Di*******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com... Hello All,
Best coding strategies for calling stored procedures from ASP.NET. As you are all aware that accessing a property is expensive than calling a method. For example in order to call a stored procedure which accepts 2 input parameters, we are currently following the below standard to set a single parameter:
objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); objOracleParameterSTATUS.ParameterName ="STATUS_IN"; objOracleParameterSTATUS.SourceColumn = "STATUS"; objOracleParameterSTATUS.OracleType=System.Data.Or acleClient.OracleType.Number; objOracleParameterSTATUS.Size =1; objOracleParameterSTATUS.Precision =0; objOracleParameterSTATUS.Scale =0; objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; objOracleParameterSTATUS.SourceVersion=System.Data .DataRowVersion.Current; objOracleParameterSTATUS.Value =STATUS; bjOracleCommand.Parameters.Add (objOracleParameterSTATUS);
So on the whole we are setting 9 properties for a single parameter and if this stored procedure accepts 10 parameters, then this process has to be repeated for those many parameters.
Can any of the solution developers suggest me an alternative choice for the above code or how can I make this less expensive and efficient.
Thanks for your help!!!
Yes - use a code generator. There are code gen tools that you can
point to a database and they can spit out all the code you need for
the tables / sprocs / views. Here is one: http://www.ericjsmith.net/codesmith/
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 13 May 2005 13:30:13 -0700, Diffident
<Di*******@discussions.microsoft.com> wrote: Instead of coding these many lines for each and every parameter, is there anyway that I can reduce the lines of code ? How can I design a resusable method for setting these properties......so that this method can be called for each and every parameter?
"Scott Allen" wrote:
Property getters and setters are generally short enough to be inlined by the optimizing compiler, so they won't be as expensive as a method call. No need to worry....
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 13 May 2005 12:41:11 -0700, Diffident <Di*******@discussions.microsoft.com> wrote:
>Hello All, > >Best coding strategies for calling stored procedures from ASP.NET. As you >are all aware that accessing a property is expensive than calling a method. >For example in order to call a stored procedure which accepts 2 input >parameters, we are currently following the below standard to set a single >parameter: > >objOracleParameterSTATUS = new System.Data.OracleClient.OracleParameter (); > objOracleParameterSTATUS.ParameterName ="STATUS_IN"; > objOracleParameterSTATUS.SourceColumn = "STATUS"; >objOracleParameterSTATUS.OracleType=System.Data.O racleClient.OracleType.Number; > objOracleParameterSTATUS.Size =1; > objOracleParameterSTATUS.Precision =0; > objOracleParameterSTATUS.Scale =0; >objOracleParameterSTATUS.Direction = System.Data.ParameterDirection.Input; >objOracleParameterSTATUS.SourceVersion=System.Dat a.DataRowVersion.Current; > objOracleParameterSTATUS.Value =STATUS; > bjOracleCommand.Parameters.Add (objOracleParameterSTATUS); > >So on the whole we are setting 9 properties for a single parameter and if >this stored procedure accepts 10 parameters, then this process has to be >repeated for those many parameters. > >Can any of the solution developers suggest me an alternative choice for the >above code or how can I make this less expensive and efficient. > >Thanks for your help!!!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: |
last post by:
I have an app that retrieves data from an Access database. At the moment I
have the SQL string as a Const in my app. I understand this is not best
practice. I don't want the user to have access to...
|
by: Fredrik Melin |
last post by:
I have a "Inventory" Object that contains the product and all its fields.
The problem is that I am getting soooooo many functions under main Inventory
class so it becames impossible to initalize...
|
by: Ren |
last post by:
Hi All,
I'm still rather new at vb.net and would like to know the proper way to access
private varibables in a class. Do I access the variable directly or do I use
the public property?
...
|
by: Jay Wolfe |
last post by:
Hello,
I'm trying to make sure I use best practices (and hence save myself some
headaches) with the declaration and definition of global variables. Let's
say I have an app with 30 files,...
|
by: Ned Balzer |
last post by:
Hi all,
I am pretty new to asp.net; I've done lots of classic asp, but am just
beginning to get my mind wrapped around .net.
What I'd like to do is include some code that tests if a user is...
|
by: MikeG |
last post by:
When creating a class library is it wrong or not a 'Best Practice' to
reference a property of an object from within a constructor or method of
that object? I recall being told not to do this but I...
|
by: kbutterly |
last post by:
All,
I have a menu which contains Category as the master and Product as the
child.
When I click on a Category in the menu, I want one formView control,
fvpc, to show, and then when I click on...
|
by: =?Utf-8?B?QW1tZXI=?= |
last post by:
I've read many incomplete opinions about the "Best Practice" for securely
accessing SQL but what I really need to find the "Best Practice" that fits my
applications needs.
Currently (alpha...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |