Tips for preparing text files (for later use by BCP)….

Naturally, the first choice is to just use BCP itself:

bcp “SELECT * MyDataBaseNameHere.MySchemaNameHere.MyTableNameHere”  queryout c:\blah.csv  -S ServerNameHere -T -t “|” -c

 Or, for those little times where you just need a delimited bunch of rows of the data in a table, do the following to leverage Sql Server Management Studio:

  1. Open a new query window.
  2. Set the Query\Results To\Results to Text
  3. Go to Query\Query Options \Results\Text and make the following settings:
    • Output format:  Custom Delimiter
    • Specify the custom delimiter
    • Turn off “Include column headers in the result set”
    • Expand the Maximum number of characters displayed ( set to the highest of 8192)
  4. Run your query, copy the text into your text file.

Ok, kind of a lame post.

 J

c# 3.5 Automatic properties….sweeeeeet….

So, in c# 3.5, this code:
public int Property1 { get; set; }

gets compiled by csc.exe into:

[CompilerGenerated] private int <Property1>k__BackingField;

public int Property1
{
    [CompilerGenerated]
    get
    {
        return this.<Property1>k__BackingField;
    }
    [CompilerGenerated]
    set
    {
        this.<Property1>k__BackingField = value;
    }
}

 Nice!

Ajax mashup (and technie goodness)

I finished that ajax book a few weeks ago.  Of course, reading never gets me too far, I always have to have my hands on the ‘ol keyboard for this stuff to actually sink in a bit more.  So, i’ve been creating a mashup that is similar in spirit to some of the examples in the book, and using a number of new or emerging technologies to do it (which is great).  Its a really simple little 1-pager app that pulls a few concepts together using the asp.net ajax library from Microsoft (and no, i’m not using the simple [but handy] update panel in any of this). 

 One thing I really noticed while reading the book was how little I’ve leveraged javascript (turns out there’s more to it than getElementById), or used it in a more traditional programming sense (um, except that whole strong-typing thing). 

 So, i set forth to create a little application that had nothing but a single javascript option instantiated, which internally, did everything from creating the UI, to making all the Ajax calls, to responding to user interaction, etc.

 I’ll swing back later and give more details and probably push the javascript goop up here soon, but basically the application brings together a custom database of people and addresses, allows for searching for items, drilling down on more detail on an item, including loading that info into Google maps, and brining in the location’s weather data (from the Weather Channel’s weather feed), and never submits the page.

Again, its really simple (the javascript object which is the workhorse has barely over 230 lines of code), but it does help solidify some of the concepts and features of some of the technologies.

Quick rundown of technologies used for this mashup:
– C# 3.5
– asp.net ajax using the native JSON support
– LINQ to SQL (minor tweaks to the sqlmetal.exe-generated code to work with the JSON serializer though, because the generated code had cyclic references, which that serializer chokes on.  Simply comment out an entitie’s parent relationship to avoid that explosion).
– WCF (the new WCF Web programming model in .net 3.5, which is how asp.net ajax can use a WCF service as an <asp:ServiceReference  />)
– Google Maps (love google)
– The Weather Channel’s weather feed (very nice, and pretty imagery too!)
– A bunch of CSS positioning, some animated gifs, and a whole lotta fun

I’ll post the code if anyone [reads this blog or…] wants it.

J

Fun with Sql Server, windows xp, and outlook web components?

Today turned out to be a fun day installing sql server 2005 dev edition today.  The machine already had Sql express 2k5 installed from the Dell factory (or would have anyhow after the VS 2005 install i did). The problem occured when I tried to install anything greater than express (namely, sql server 2005 dev or standard edition(s)).  I intially had to back everything out of the machine to get it to stop complaining about the need to upgrade, and then once those were gone, the OWC11 portion kept failing (apparently Office Web components).  Those things looked installed, via a glance in add/remove programs (plus reflecting on the zillions of other machines with various installations with which never had this problem).  Googling, I found articles about temp file locks and such, so I cleaned up files, directories, and rebooted and such.

This blog entry turned out to be the simple solution. 

Nice way to filter Report Viewers export formats

Thanks to this guy’s article, which shows a decent way to hide reporting service’s export formats from the report viewer, without making global changes to the entire server and such.  If you look at the code, his sample requires a reference to the ReportingServices2005 stuff, so here’s a slight modification of one of his routines which removes that dependency (additionally, we subclassed the ReportViewer itself, but the decorator pattern used in the article is equally compelling): private void ReflectivelySetVisibilityFalse(RenderingExtension extension)
{
FieldInfo info = extension.GetType().GetField(“m_serverExtension”,
BindingFlags.NonPublic | BindingFlags.Instance);
if (info != null)
{
object actualExtension = info.GetValue(extension);
if (actualExtension != null)
{
PropertyInfo propInfo = actualExtension.GetType().GetProperty(“Visible”);
if (propInfo != null && propInfo.CanWrite)
{
propInfo.SetValue(actualExtension,
false, null);
}
}
}
}

Ajax

I’m reading this book right now and enjoying it big-time.  It also makes me realize how much i’ve been missing out by not pushing javascript much harder.  The book takes you through the lower-level details of Ajax, such that when you use something higher level , then you can appreciate/understand a bit more of the magic behind the scenes.  Anyhow, a good read and a relevant skill for any current web developer to have.

Reporting Services – A collection of work-arounds

If you have any reporting beyond trivial needs, I urge you to avoid Sql Server Reporting Services.  For example, if you want

  • A templating mechanism (like a “Master Page for reports”…Data Dynamics has this)
  • A Theming/styling mechanism
  • The need to have reports dynamically pull from different databases
  • The need to have available report parameter values dynamically pull from different databases
  • Need data items in headers/footers
  • Want a viewer that is’nt [broken and..] married to the workflow of creating reports
  • An API for the report definition language

Then go buy a solid reporting technology (some of this may be alleviated with Sql 2008, but many will not).  I suggest looking at Data Dynamics.