Archives
-
Exporting a SQL Server Reporting Services 2005 Report Directly to PDF or Excel
Exporting a SQL Server Reporting Services 2005 (SSRS) Report Directly to PDF/Excel is a handy way of generating high quality reports without being stuck to using the ReportViewer interface. Sometimes the ReportViewer interface is an unnecessary step, but other times the ReportViewer won't render correctly even though the underlying report is correct. This is especially true when your audience might use Firefox or Safari (or anything other than IE), since the ReportViewer control almost never outputs a readable report. Of course it would be nice to just have a button on your page that generates a PDF or Excel file in any browser, and uses a SSRS back-end to do all of the report creating and heavy lifting.
-
.NET 2.0 Cast operator vs. As operator
When I was converting untyped data values from a SQL database into a custom Business class, I realized that I have to take a special precaution when casting possibly null values. If you try to cast DBNull to some type, you will get an InvalidCastException. When thinking about a solution, I remembered the as operator and decided to do some investigating. Consider the following example:
-
Creating a Custom Code Snippet
Creating a Custom Code Snippet is pretty easy to do -- you just fire up your favorite text editor, write some XML, and save the results in a *.snippet file. If you use Visual Studio as your text editor, you can even get some XML Intellisense, which is always nice. I am going to create a code snippet called rw.snippet, which will simply expand to Response.Write();, and leave your cursor inside the parenthesis (something I use far too often, along with Trace.Write(), for debugging).
-
Visual Studio Tip: Use Code Snippets
There is a little used function of Visual Studio that will save you a lot of coding time: Code Snippets. Code Snippets are handy key shortcuts that expand into commonly used .NET constructs such as regions, constructor, loops (do/while/for/foreach), and try/catch blocks. To use a code snippet you can type in its 'shortcut' and in Intellisense you will see a little piece of paper next to the word indicating that it is indeed a code snippet. Then you press TAB twice, and the code snippet is expanded into the full construct, and depending on the snippet you may be directed to enter some pertinent information.
-
Using ASP.NET AJAX (and other DLLs) in a remote debugging environment
My development environment involves working on code that is not stored locally on my machine, but on a centralized development server on our network. I like working this way because it allows me to decouple my computer from IIS, and running the remote debugger (comes on the Visual Studio 2005 DVD) is really simple.
-
Using BLL objects with Parameterized Constructors in an ObjectDataSource
If you use BLL objects with ObjectDataSources to populate your GridViews, DropDownLists, etc, the ObjectDataSource tries to instantiate your BLL object using a parameterless constructor. If you don't have a parameterless constructor (I usually don't) available, you'll get and error like:
-
aspnet_compiler.exe exited with code 1
After coding a .NET 2.0 project in VS 2005, I built and ran the project successfully with no compiler errors or warnings. However, once i added a Web Deployment Project and tried to compile it, it gave me the error "aspnet_compiler.exe exited with code 1". After doing some searching, I was able to find (more or less) the problem by running the aspnet_compiler manually with the error stack. The steps I followed are summarized below: