|
Yeah, and I even considered doing that for about three minutes, and then decided it was a hack (although no less of a hack than using reflection).
Besides that, putting the parameters into a list would have required the extra overhead of traversing that list in order to fill the SqlCommand's internal collection object, where simply assigning the collection requires just one line of code.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Wednesday, February 27, 2008 10:58 AM
|
|
|
|
|
John Simmons / outlaw programmer wrote: Besides that, putting the parameters into a list would have required the extra overhead of traversing that list in order to fill the SqlCommand's internal collection object, where simply assigning the collection requires just one line of code.
No it wouldn't. You would use Parameters.AddRange to add the parameter collection. You should never traverse a collection to add it to another collection. You should always look to use the AddRange method (if available) as it's much more performant.
|
|
|
|
|
John Simmons / outlaw programmer wrote: I wrote a function in a class that accepts a stored procedure name and, curiously enough, an SqlParameterCollection, and returns a DataTable - all of the nasty sql stuff is contained in the function
Well, no. If you have the SqlParameterCollection being passed into the method, then "all of the nasty SQL stuff" is no longer contained just in the method.
|
|
|
|
|
The class is a generic class that simply handles all of the SqlConnection, SqlCommand, and SqlDataAdapter stuff with the requisite exception handling. All I have to do to instantiate the object is pass in either a query string or a app.config keyname for the query string, and then call the appropriate function, some of which allow you to pass parameters. Granted, I could have written a class that inherited my SQLQueries class to hide even the SqlParameterCollection stuff, but that needed to be put off until later.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: So I want to create an instance of SqlParameterCollection.
You always have to do it through SqlCommand class. That is what serves as the factory for parameter collection. Parameter collection belongs to and works in close association with the command object. Things are internal or protected for a certain reason.
You are breaking Good OOP practices by using reflection. For instance, what will happen when in next version of .NET Microsoft decides to add a new internal constructor and decides to get rid of the default constructor. Your code will compile fine but will never run.
As people have suggested List<sqlparameter> is a slightly better option. But I would prefer to get rid of even that and use a method like this:
void ExecuteQuery(string query, IDictionary<string, object=""> values); </string,>
or even better
void ExecuteQuery(string query, params object[] values);
The later one requires a little extra work, but is a better option IMO.
You have, what I would term, a very formal turn of phrase not seen in these isles since the old King passed from this world to the next. martin_hughes on VDK
|
|
|
|
|
Hai
I need to add and remove rows dynamically to an html table on button click event. In my code only one row is created and that row removes on another click.
Please help me
|
|
|
|
|
Please don't cross post.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any microsoft's UI toolkit for .Net?
|
|
|
|
|
Which particular UI? Office? Visual Studio? Money?
|
|
|
|
|
Be more specific, please
"That's the problem with a spell checker. It only helps with bad spelling, not stupidity." - Rob Graham
|
|
|
|
|
I wud like to know the GUI toolkit for Dotnet from Microsoft?
|
|
|
|
|
Like Pete said. What GUI toolkit? Your question is rather vague...
"That's the problem with a spell checker. It only helps with bad spelling, not stupidity." - Rob Graham
|
|
|
|
|
do you expect something similar to "swing", "awt" or "swt" from java world?
|
|
|
|
|
Hi,
I am having a problem that I have been trying to solve for the last 2 weeks. This might be seen in many travel sites like lastminute.com. The situation is simple. I need an indeterminate progress bar. I enter the search criteria/parameters (From/To Date & Destination) in page ‘A’. I click the search button now. I need to be transferred to Page ‘B’, which is empty but consists of a progress bar like image displaying any message and then I need to be transferred to page ‘C’ where the results will be displayed. I use the term “Indeterminate”, coz the progress bar is displayed based on the time taken (which can vary) to display the results and it not a fixed time interval(Usually with thread. sleep type) like u see in many sites. I am using VS 2005 + MS SQL 2005 + ASP.NET 2.0 + AJAX 1.0. Please help me out.
|
|
|
|
|
Don't double post, it's considered rude.
|
|
|
|
|
I am developing one application. In that application I am developing one software tool or wondows. With help of that window I wantto control protocoles of the internet. For that I need to identify protocol or packet and test it and then after decide to accept or drop that packet.
For this purpose I am using "OpenVPN" and creating two ports and programming in between those two terminal.
But I an cofused is tehre any sources available for that or is that a right base or any simple method is possible ?
Thanks
vikram d patel
|
|
|
|
|
I have a problem with my applications on German OS machines in which I find that the applications crash and the .NET Runtime is reporting exceptions into the Event Viewer.
The same applications running on an English XP Pro SP2 do not crash. Both installed using the same installer.
I appreciate that it may be something I have overlooked. Are there any subtle differences? Is there a specific German version of the .NET runtime that I ought to be installing?
Thanks in advance for your time
Regards
Ant
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
Here's the one that bit me once or twice. A number in the US or UK is 2,000.01. In Germany, it's 2.000,01. That difference of numbering format has caused me some grief a number of times, it's a strong candidate for the root cause of your error.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the tip (I've come across this sort of thing in the past when developing Macros for Excel and Word). I just wouldn't expect such an abrupt end to the application.
Many thanks, I'll concentrate on this come Monday morning.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
Sounds like you're hitting a culture issue. As Christian has said, take a look at things like the diff between the decimal and thousand separators, but also take a look at datetime formats. These are the two that normally step up and bite you in the ass.
|
|
|
|
|
I assumed English to mean UK, but you're right, if it's US, the date is at least as likely to be it. I've seen so much code that bypasses the DateTime class and just string mangles to seperate dates - as I am in Australia, any project I get pulled into from the US, I quickly work out those sort of issues.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
And thanks for the date time tip Pete. As stated to Christian I wouldn't have expected such an abrupt end to the application.
Many thanks for the advise.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
No problem. Unfortunately, formatting errors do tend to be nasty little bugs and they do cause all sorts of exceptions to be thrown.
|
|
|
|
|
FYI, The problem was indeed a cultural one. It was down to a configuration file used to setup Remoting.
An IPC channel was being used and naively I set the authorizedGroup="Everyone". I now pre-process the file and replace a placeholder variable with the appropriate WorldSid name (this is OS agnostic).
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
Since .NET Framework 2.0, Response.TransmitFile is an elegant way to transmit huge files without buffering. Somewhere I have read in a Microsoft KB regarding the number of concurrent executions of Response.TransmitFile. In other words, the maximum number of connections to the web server using Response.TransmitFile. I feebly recall the figure as 50.
Any one remember that Microsoft KB URL which mentions this?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
modified on Friday, February 22, 2008 11:52 AM
|
|
|
|