.net

Sorting the result of a stored procedure

I'd like to sort on a column in the result of a stored procedure without having to add the Order By clause in the stored procedure. I don't want the data to be sorted after I have executed the query, sorting should be part of the query if possible. I have the following code: public static DataTable RunReport(ReportQuery query)...

Is there a way to check the SQL generated by ADO.NET methods without resorting DB tracing/profiling?

I want to test that application A (legacy) and application B (current) are sending the same SQL to the database. Is there an easy way to check the generated SQL? I'm not too concerned with minor syntax differences. ...

Handling very large strings between SQL Server and .NET code +LINQ

I have an app that needs to handle very large strings between a SQL Server database and .NET code. I have a LINQ query that generates the strings when saving them to the database, but when trying to create the strings from the database, the app crashes with an OutOfMemoryException because of the size of the strings. Do I have to do some...

Generic ThreadPool in .NET

Here's a relatively common task for me, and, I think, for many a .NET programmer: I want to use the .NET ThreadPool for scheduling worker threads that need to process a given type of tasks. As a refresher, the signatures for the queueing method of the ThreadPool and its associated delegate are: public static bool QueueUserWorkItem ( ...

Heterogeneous Dictionary, but typed?

This is more of an academic inquiry than a practical question. Are there any language or framework features that can, or will in future, allow a heterogeneous typed dcitionary, e.g. myDict.Add("Name", "Bill"); myDict.Add("Height", 1.2); where myDict now contains not two object types as values, but one string and one double? I coul...

Is There A Way to Use Overrideable Behaviour in a Call to a Base Class Constructor?

The title is a bit abstract so maybe it is easier to explain with a specific example: I find it useful to have my exception classes take an enum parameter instead of a string message. throw new SpecificException(SpecificExceptionCode.ThisThingWentWrong); There are few reasons for this, including: I can encapulate all the logic for...

Regular expression to match a string (1+ characters) that does NOT end in .ext

I need to test a url that it does not end with .asp So test, test.html and test.aspx should match, but test.asp should not match. Normally you'd test if the url does end with .asp and negate the fact that it matched using the NOT operator in code: if(!regex.IsMatch(url)) { // Do something } In that case the regular expression would ...

"Cannot call methods on DateTime", and other limitations

Does anyone know of a definitive list of LINQ to SQL query limitations that are not trapped at compile time, along with (where possible) workarounds for the limitations? The list we have so far is: Calling methods such as .Date on DateTime no workaround found string.IsNullOrEmpty simple, just use == "" instead .Last() we used .Or...

which one would you use to draw stuff on a winform? Format32bppRgb or Format24bppRgb or something else?

in any .net version Format24bppRgb Specifies that the format is 24 bits per pixel; 8 bits each are used for the red, green, and blue components. Format32bppRgb Specifies that the format is 32 bits per pixel; 8 bits each are used for the red, green, and blue components. The remaining 8 bits are not used. ...

Typed DataSets with XML data sources and schemas

I've written an XML Schema file by hand (not using the DataSet Designer in VS) and a corresponding XML file containing structured data to be read in. I ran the xsd.exe program to generate a Typed DataSet class; on the whole it looks fine to begin with (ignoring how it uses lowercase for public class members), but when it comes to using ...

How to analyse .exe parameters inside the program?

I have a program that can have a lot of parameters (we have over +30 differents options). Example: myProgram.exe -t alpha 1 -prod 1 2 -sleep 200 This is 3 Commands (from command pattern object at the end) that each contain some parameters. Inside the code we parse all command (start with -) and get a list of string (split all space) fo...

Event handling in Visual C++

There are two pictureboxes with two different images. If I click on one picture box, the image in it should be cleared. To make the matters worse, both of the picture boxes have only one common event handler. How can I know which picturebox generated the event? I would appreciate source code in Visual C++.net I need to know what to wr...

Windows temporary files behaviour - are they deleted by the system?

Using the .net framework you have the option to create temporary files with Path.GetTempFileName(); The MSDN doesn't tell us what happens to temporary files. I remember reading somewhere that they are deleted by the OS when it gets a restart. Is this true? If the files aren't deleted by the OS, why are they called temporary? They are...

Find out the size of a .net object

I'm trying to find out how much memory my objects take to see how many of them are ending up on the Large Object Heap (which is anything over 85,000 bytes). Is it as simple as adding 4 for an int, 8 for a long, 4 (or 8 if you're on 64 bit) for any reference types etc for each object, or are there overheads for methods, properties etc. ...

I cannot change the target .NET Framework in IIS 6

The option to target another version of the .Net Framework is disabled on a particular test system we are using on a current project. I have tried the following without success: Killing all W3WP.EXE processesRestarting the IIS serviceRemote Debugging has been removed from the box. Just hoping for some pointers. ...

Setting a publish page content programatically

Hi there, I want to know how to set a Publishing page content through the code (MOSS 2007).This is how I've created the page: PublishingPage page = publishingWeb.GetPublishingPages().Add("MyPage.aspx", pageLayout); SPFile pageFile = page.ListItem.File; page.Title = "My Page"; page.Update(); But all my attempts of ...

How do I independently change the width and height of a font in .NET?

Given something like this: thefont = New Font("Courier New", fontheight) and this: ' g is a Graphics object g.DrawString("some text", thefont, Brushes.Black, X, Y) what can I put in the middle of the two to change the width of the font, so that "some text" is expanded or compressed horizontally but the height remains the same? ...

removing the "T" from a datetime when doing a xml+xsl=html with .net (XmlDataDocument,XslCompiledTransform,XmlTextWriter)

what is the easiest way to remove the "T" from the result? I want the result to be "YYYY/MM/DD HH/MM/SS" the vb.net code is really straight forward xmlDoc = New Xml.XmlDataDocument(data_set) xslTran = New Xml.Xsl.XslCompiledTransform xslTran.Load(strXslFile) writer = New Xml.XmlTextWriter(strHtmlFile, S...

Is there an equivalent to the .Net FileSystemWatcher in the Linux world?

I find the .Net FileSystemWatcher class really handy for writing utilities that automatically come to life when files show up in their watched folders. Is there any equivalent to this functionality in the *nix world that would allow me to watch a folder (and possibly all of its subdirectories)? Edit: Preferably this will be something th...

Bizarre Firefox Input Bug

I'm a bit flabbergasted at this, so I'm wondering if any SOers have encountered it before. I have an essentially flat page with a number of input=text seeded in the markup with default values of say A,B,C,D,E in order. The markup looks like this in view source: <td class="action invoice"> <a href="#foo">Toggle Invoice</a> <div clas...