|
i tried the following code
class abc
{
ParameterCollection p;
public ParameterCollection ab
{
get
{
return p;
}
}
}
public class waste
{
public waste()
{
abc a;
a = new abc();
a.ab.Add("ParameterName", TypeCode.Decimal, "ParameterValue");
a.ab[0].Direction = ParameterDirection.Output;
a.ab[0].Size = 100;
}
}
can i improve the code?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
I generally use a set of helper methods. Roughly, they do the following:
public static DbParameter Parameter<T>(string parameterName, DbType parameterType, T value, int size)
{
DbParameter param = Parameter(parameterName, parameterType, value, ParameterDirection.Input);
param.Size = size;
return param;
}
public static DbParameter Parameter<T>(string parameterName, DbType parameterType, T value)
{
return Parameter(parameterName, parameterType, value, ParameterDirection.Input);
}
public static DbParameter Parameter<T>(string parameterName, DbType parameterType, T value, ParameterDirection direction, int size)
{
DbParameter param = Parameter(parameterName, parameterType, value, direction);
param.Size = size;
return param;
}
public static DbParameter Parameter<T>(string parameterName, DbType parameterType, T value, ParameterDirection direction)
{
DbParameter param = new DbParameter();
param.Direction = direction;
param.Name = parameterName;
param.DbType = parameterType;
param.Value = value;
return param;
} Then, all you need to do is
cmd.Parameters.Add(Parameter("@ID", DbType.Int, 100));
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete, that seems a lot of work for what I usually do:
<br />
int value1 = 10;<br />
cmd.Parameters.Add(new SqlParameter("@param1", value1));<br />
Or am I missing something?
I do not believe they are right who say that the defects of famous men should be ignored. I think it is better that we should know them. Then, though we are conscious of having faults as glaring as theirs, we can believe that that is no hindrance to our achieving also something of their virtues. - W. Somerset Maugham
My New Blog
|
|
|
|
|
Brady Kelly wrote: Or am I missing something?
Sort of. The full version that I have takes care of a lot more than this, and is standardised so that more complex types of parameter can easily be created.
There's been a lot of work put into the library to ensure that it copes with a wide variety of cases - including things like automatically putting the right parameter modifier (e.g. @) onto a parameter name, based on the database type. It's sort of a cut down version of the Enterprise Library, and it means that we can target multiple databases with the same codebase, just by changing an entry in the config file.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Aah, thanks. Would you mind clearing something up for me please? The excerpt generates a compiler error for trying the call the protected constructor for DbParamter. Were you just generalising for the example? If so, I'm curious to know how you implement concrete helpers.
I do not believe they are right who say that the defects of famous men should be ignored. I think it is better that we should know them. Then, though we are conscious of having faults as glaring as theirs, we can believe that that is no hindrance to our achieving also something of their virtues. - W. Somerset Maugham
My New Blog
|
|
|
|
|
This was a very generalised example, mainly to demonstrate the fact that you can use a DbParameter. Our routines actually accept the DbCommand and use the CreateParameter method on this. One hint as to why we don't use the Enterprise Library - our routines can work with delegates (anonymous methods), attributes and default values. They've grown over the years, as our experience/needs with our clients has grown.
One day, I might write an article on them and detail how they've grown. It's an interesting way to document how infrastructure evolves with client demands.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
what is DbParameter in this context?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
If you just target SQL Server, just replace this with SqlParameter. DbParameter is the base class that SqlParameter derives from, and (as noted in the other posts in this thread), requires slightly different behaviour.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Pete....
can u tell me something about <T> in the following context.
<code>public static SqlParameter Parameter<T>(string parameterName, DbType parameterType, T value, ParameterDirection direction)</code>
-- modified at 7:52 Friday 12th October, 2007
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
-- modified at 7:52 Friday 12th October, 2007
|
|
|
|
|
It's a generic parameter. It basically means that you can pass the value in without having to box it to an object then unbox it. Without this, you would have to declare object value .
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I have a MdiParent Form, that contains MdiChild forms. That MdiParent also contains some controls on it (panels). Default MdiChild Form behavior is that it is displayed behind all control's on MdiParent. So if there is a panel on MdiParent and I drag a MdiChild so it interferes with panel, panel is in front of it and I can't see the MdiChild part behind the panel.
Is there any simple way how to change this default behavior, so that MdiChildren are in front of all MdiParent - controls ?
zilo
|
|
|
|
|
Hello,
I think there is only the possibility of "BringToFront()"
All the best,
Martin
|
|
|
|
|
Hi,
didn't help, I removed those controls...
thanx for aswer
zilo
|
|
|
|
|
Zilo(svk) wrote: Is there any simple way how to change this default behavior
No. This cannot be changed. All MDIChild forms are rendered on a control docked as Full in the MDIParent form. This control is called the MDIClient. Any other controls you place on the MDIParent form will always hover over the top of the MDIClient control.
You will have to either get the reference to the MDIClient control (it's in the MDIParent form's Controls collection, just like any other control), and turn off it's Dock property, and resize it to give you room to put your other controls on the MDIParent, OR you put all of you're other controls in their own seperate window.
|
|
|
|
|
Hi,
I want to that then click a back and forword internet explorer button then appear message in asp.net C#
|
|
|
|
|
What sort of message ? Do you want to forbid it, or just pop up some message ? I'm not sure that javascript can tell that you've pushed those buttons, if it can, then you can write javascrpt to do that.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
what the best biometric fingerprint scanner or reader that is easy to manipulate using c# or vb.net?
im about to purchase one to be used in one of my client. we will be using it for employee daily time record.
can anyone point me to the right direction of what type/model/brand to use? i have not used this type of equipment before.
thanks in advance
-TheCardinal
|
|
|
|
|
Not sure what is the best. Have you browsed around?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi!!
Maybe I can help you. In a recent project I have test two models from different manufacturers:
-DigitalPersona...
-FingKey Hamster
We decided to decline DigitalPersona because is too slow starting when operating system starts and to capture fingerprint. Hamster doesn't not. IS very fast and has a payment sdk with samples to c# with a low cost. And now you have a second version on Hamster(Hamster II). I recommend it.
Look here -> http://www.nitgen.com/New_site/eng/product/pc_hamster.asp
I hope this help you.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
thanks il_masacratore!
Your reply is highly appreciated. ill take a look and it.
-TheCardinal
|
|
|
|
|
Hi all
I have a requirement to get the http port number,Server location and web server port in which the web site is running using CSharp.Any web reference or code help is appreciated.
Regards
Krish
|
|
|
|
|
Try looking at these keywords/classes HttpWebRequest,HttpWebResponse....
VirtualVoid.NET
|
|
|
|
|
Is it possible to write C# coding and VB.Net Coding in the ASPX page
Regards,
LEE
|
|
|
|
|
yes u can write coding in aspx pages
in <% %> Server tags.
Thanks and Regards
Aavesh Agarwal
|
|
|
|
|
I tried using <% %> Server tags but i got error msg.....
Can you give me an examples or Sample coding
Regards,
LEE
|
|
|
|