Living in Code

Ramblings from a code monkey

SQL Server 2008 RTM released!

Not that I think I'm breaking any news here, but SQL Server 2008 has been officially RTM (released to manufacturing).  So far I've been very pleased working with SQL Server 2008 and am excited to get my RC0 version updated to an official release.

One thing I stumbled across was a warning users to wait for Visual Studio.NET 2008 SP1 to be released BEFORE upgrading to the RTM version of SQL Server 2008.  This blog post cites compatibility problems if you don't have SP1 installed before working with the RTM version of SQL. What I'm not sure about is if this applies to people using beta versions of SQL Server 2008 (RC0), Visual Studio 2008 SP1 and .NET Framework v3.5 SP1 like I am.  This uncertainty made me think that it may be best to wait for the final release of SP1 for VS.NET and the 3.5 Framework.

I then came across a nugget here that said:

well....there's a...ahem...NDA about this topic...but SQL Server 2008 RTM ships with a RTM version of the .NET Framework 3.5 SP1 bits...i'll let you connect the dots.

I guess it's time to dig around in the RTM version of SQL 2008 to see if it's there.  I also wonder if it's safe to install over top of my RC0 version of if I should remove RC0 before installing the RTM version.  I guess I'll have to Google more to see what's required.  I'll provide updates as I find answers and get upgraded.

**** Update:

According to the release notes the beta SP1 isn't an acceptable solution.  And since they're saying SP1 will be officially released next week anyways, it makes sense just to wait for that I think.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Software | SQL Server
Posted by Don on Friday, August 08, 2008
Permalink | Comments (0) | Post RSSRSS comment feed

What's wrong with my Linqdatasource? - Method not found!

I've been having a very weird problem in Visual Studio 2008 when trying to use the automatic operations for the Linqdatasource (insert, update or delete).  It seems that no matter what I try I get this weird "Method not found" problem.  Unfortunately there doesn't seem to be a lot of help out on the web about why this may be happening.  I'm starting to think that there may be something goofed up with my 3.5 Framework or Visual Studio 2008.

Here's the error and a link to the problem I posted out on the ASP.NET forums.  If anybody has come across this weird problem let me know. Unfortunately the 1 person that has replied on the discussion forums hasn't been much help and offers up only basic suggestions as to why it may not be working, all of which were things that I had already known or tried right off the bat.

System.MissingMethodException: Method not found: 'System.Object System.Web.UI.WebControls.Parameter.GetValue(System.Object, Boolean)'.

Generated: Mon, 04 Aug 2008 12:40:10 GMT
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.MissingMethodException: Method not found: 'System.Object System.Web.UI.WebControls.Parameter.GetValue(System.Object, Boolean)'.
at System.Web.UI.WebControls.LinqDataSourceView.MergeDictionaries(Object dataObjectType, ParameterCollection reference, IDictionary source, IDictionary destination, IDictionary destinationCopy)
at System.Web.UI.WebControls.LinqDataSourceView.BuildInsertDataObject(Object table, IDictionary values)
at System.Web.UI.WebControls.LinqDataSourceView.ExecuteInsert(IDictionary values)
at System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback)
at System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation)
at System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.sellyourhome_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: LINQ
Posted by Don on Friday, August 08, 2008
Permalink | Comments (2) | Post RSSRSS comment feed

2008!!

Wow, it's been quite a while since I've posted.  It was just into 2008 back in January.  Wow how time flies!

 Well, 2008 has brought many new versions of the tools that I use on a daily basis for my job.  Visual Studio has a 2008 version out.  Microsoft SQL Server has their 2008 version out (well, RTM will be next month so they say).  Also the .NET Framework is cranking along with the 3.5 framework which they are almost out with a final release of SP1.

I am excited that my job and the project I'm currently working on has given me the ability to upgrade to the latest versions of these tools.  So far I've been the most excited with SQL Server 2008 and all of the new features it has to offer.  Intellisense for T-SQL, now that's nice!

I'm also anxiously awaiting Apple's rumored update of their MacBook Pro laptop line.  Once they come out I'm going to get one and beef it up for my .NET Development.  I know many .NET developers out there would never think of owning a Mac, but man... once you go Mac you never go back!  My desktop at work is a HP workstation with Windows XP and I can't even tell you how many times I need to reboot to keep things running smoothly.  It's sad that as a Windows user I just am in the habbit now of rebooting when I leave for the day or when I go out to lunch.  With the Mac, I'm like "gee, I haven't rebooted in a few weeks, I should probably just do it for the hell of it."

Family life has been keeping me busy too.  We welcomed our 3rd child this past March and have been knee deep in kids!  Our twins turned 2 in June and they're getting smarter and smarter with each day that passes.  It scares me that they'll no doubt have me/us tied up in a closet at some point as they take over the house.

I am going to make an effort to post more moving forward.  God knows I come across enough technical things that would probably be helpful to others.  I'm learning to work with LINQ (also, here, scroll down to LINQ section) and can't wait to get more into that.  Also, SubSonic, a great tool, is out with a new version.  I'll be playing with that too when building an application I'm working on for my side-business.

Stay tuned!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: .NET | LINQ | Mac
Posted by Don on Wednesday, July 16, 2008
Permalink | Comments (0) | Post RSSRSS comment feed

Testing email when working with no SMTP server

Happy New Year!

While this tip isn't my own, it still seems as though it will be very helpful.  I know that I do a lot of development locally where I don't have an SMTP server setup.  This tip, courtsey of .NET Tip of the Day, really will eliminate that problem and allow you to work with email without the headaches.

--- 

Testing code that sends email has always been a pain. You had to set up a SMTP service just to test that your .NET application sends the e-mail correctly.

However, there is a way to send e-mails with no SMTP server set up. Just configure your .NET application to drop e-mails into a specified folder instead of sending them via SMTP server:

<system.net>

   <mailSettings>

      <smtp deliveryMethod="SpecifiedPickupDirectory">

         <specifiedPickupDirectory pickupDirectoryLocation="c:\Test\" />

      </smtp>

   </mailSettings>

</system.net>

This will instruct SmtpClient class to generate mail message, save it as .eml file and drop it into c:\Test\ folder.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,
Categories: .NET
Posted by Don on Wednesday, January 09, 2008
Permalink | Comments (0) | Post RSSRSS comment feed

VB.NET RC4 Encryption for database storage

I recently had to upgrade some Classic ASP code to .NET for some data encryption.  The routines use RC4 encryption and make the result database friendly.  The following class can easily be dropped into your project for use with little effort.  The sample code shows the encryption and decryption methods.  You just provide the message and the key for either instance.  From there you can drop it in your database or do whatever you want!

Sample Usage:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim plainText As String = "I'm exposed!"
        Dim passkey As String = "keep me safe"

        Dim safeText As String
        safeText = Common.Encryption.Encrypt(plainText, passkey)

        Response.Write(safeText)

        Dim decrypted As String
        decrypted = Common.Encryption.Decrypt(safeText, passkey)

        Response.Write(decrypted)

    End Sub

 You can view the entire class here.  If you're looking for some quick and easy encryption this will do the trick.

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Don on Wednesday, November 28, 2007
Permalink | Comments (2) | Post RSSRSS comment feed

CMD Email updated

The email command line utility I wrote (and discussed here), CMD Email, has been updated.  The latest release supports email attachments.

You can download the latest runtime or source from the project page on CodePlex. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: CmdEmail
Posted by Don on Tuesday, November 27, 2007
Permalink | Comments (0) | Post RSSRSS comment feed

CMD Email - command line email utility

I've completed my first open source project.  I have been wanting to put something out on Codeplex for a while and finally got around to it.  The project I released is a small little command line email utility that uses the .NET 2.0 framework.  I wrote a more simple version of this years ago to email me when Windows scheduled tasks (batch files) completed.  The released version accepts many more options and allows you to store certain data into an application configuration file.

As this post title states, the utility is called CmdEmail and can be found here on codeplex.  From the project page you can download the latest (initial) release, see usage information and access the source code too.  Here's a blurb on the usage from the project's home page:

Usage:

CmdEmail -f nobody@nowhere.com -t you@domain.com -s Subject -b Body
CmdEmail -f "nobody@nowhere.com" -t "you@domain.com" -s "Subject" -b "Body"
CmdEmail -f nobody@nowhere.com -t you@domain.com,me@domain.com -s Subject -b Body
 
All command switches:
 
t, to         Required. Recipient (To)
f, from       Required. Sender (From)
b, body       Required. Email Body
s, subject    Required. Email Subject
h, host       SMTP Server - Optional only if provided in app config
p, port       SMTP Port - Optional, can also be provided in app config
u, username   Username - Optional, can also be provided in app config
p, password   Password - Optional, can also be provided in app config
help

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: CmdEmail
Posted by Don on Friday, October 26, 2007
Permalink | Comments (1) | Post RSSRSS comment feed

Technorati

Technorati Profile

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Don on Tuesday, October 02, 2007
Permalink | Comments (0) | Post RSSRSS comment feed

Learn how to write better code for free!

Use FxCop to write better code.  I've been using it for a little while now and it definitely has helped me out.

This article tells you how and why! 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: .NET
Posted by Don on Wednesday, September 12, 2007
Permalink | Comments (0) | Post RSSRSS comment feed

How to enable IntelliSense in .skin files in Visual Studio 2005

A co-worker of mine shared this with me recently.  It was one of the biggest annoyances in Visual Studio 2005 if you ask me!

How to enable IntelliSense in .skin files

IntelliSence everywhere! That's one of the biggest features in new Visual Studio .NET 2005 (VS 2005). But guess what, it doesn't work out of the box in .skin file  - the place you really need it. Those of you who worked with ASP.NET 2.0 themes understand me . Good news - there is a workaround to enable this feature. Do the following:

1. Go to Tools->Options menu.

2. Pick Text Editor -> File Extesion fom a tree at the left part of Options dialog.

3. Type skin in Extesion text box.

4. Select User Control Editor from Editor dropdown.

5. Click Add and then Ok to close dialog and re-open your skin files.

6. Say something corny about Microsoft.

Enjoy!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: .NET
Posted by Don on Tuesday, August 28, 2007
Permalink | Comments (0) | Post RSSRSS comment feed

Very cool, very free Remote Desktop management utility

While bragging to my buddy Bill about how cool this new open source remote desktop app Terminals was, he showed me an even better tool, visionApp Remote Desktop (vRD), that he uses for the same thing. After a quick 5 minute install and configuration I clearly liked vRD over Terminals and any other RDP tool I had used.

Here's a blurb from the vendor's website about the program:

vRD is a tool which allows the management of RDP connections to servers. vRD is ideal for administrators who need to maintain simultaneous connections to multiple servers. Connection-specific settings and login credentials can be organized in folders and subfolders for quick access.

The new version 1.5 further extends the ease of use. Coming, amongst others, with support for Microsoft Vista, support for multi-monitor environments, support for setting the color depth and support for setting various performance options, vRD 1.5 offers many new features for hassle-free handling of multiple RDP connections.

I definitely suggest checking out this freeware app if you're a frequent user of numerous RDP connections.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Don on Thursday, July 19, 2007
Permalink | Comments (0) | Post RSSRSS comment feed

Control multiple computers with a single keyboard and mouse

I recently reformatted my Dell Laptop and put Windows XP back on it.  My wife had been using it for the past year or so and I found that I was wiping it every few months.  So at one point I put Ubuntu Linx on it to help prevent the "wipe cycle".  It worked out well but she really was't using it much anymore and I found I wanted to get it setup to work with the VPN we're setting up at my office.

 So, I got Windows XP back on it and got all my development tools setup on it.  I've been running it at the office next to my desktop and remembered seeing an article on Lifehacker a few months ago about some software that let you basically have a software based KVM switch.  So, I went back on their site and found this article.  And, after about 10 minutes of setup time, I'm happy to report that Synergy, the application they used, works like a champ!

Even though I'm not taking advantage of it at the moment, the best feature about this app is that it's cross platform.   Oh, and did I mention that it is free?  Gotta love the opensource!

Here's a snippet from the article I linked to above...

You don't need a hardware switch to share one keyboard and mouse amongst several different computers. All you need is the free, cross-platform application, Synergy.

Synergy connects one keyboard and mouse to any computer on your network, making a dual- or triple-computer setup work more like a dual- or triple-monitor setup. Synergy even allows you to share clipboard data across your computers and operating systems.

Today I'll detail how to set up Synergy on your home network to control all of your desktops with one mouse and keyboard.

How it works

Synergy uses one computer as a server - that's the computer that will be sharing its keyboard and mouse. The rest of your computers - the ones you want to control - will need to be set up as Synergy clients.

The great part about Synergy is that you can customize the program to work with the layout of your computers. For example, if you've got your MacBook running to the left of your Windows PC, you can set up Synergy so that moving your mouse to the left of your Windows monitor will seamlessly jump your mouse across virtual space where it lands safely on your Mac. Whichever desktop currently holds your mouse is also the desktop to which your keyboard's keystrokes will be sent. Make sense? Add to that Synergy's clipboard sharing and you've got one helluva convergence app.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Don on Monday, July 16, 2007
Permalink | Comments (3) | Post RSSRSS comment feed

FormView and ObjectDataSource with nullable types

I recently ran into this problem when using a FormView and and ObjectDataSource where the FormView was binding to nullable data types...

Here is a challenging question, as I have not found any suitable information on this after two days of searching:

Background:

I have a custom Business Class library that includes custom objects with nullable int and DateTime properties. In order to update this data, I have created a FormView control bound to an ObjectDataSource that retrieves a generic List collection of my business objects. The reflection that is intrinsically called by the FormView/ObjectDataSource combination dutifully builds my basic Select, Update, and Insert templates. Now, when you edit the various (TextBoxes by default) input fields and then call the Update method referenced in the ODS (ObjectDataSource), the ODS attempts to convert the data contained in the input fields to the corresponding Type of the property bound to said input field. This is where we run into our little problem...

Even though I have a nullable Integer property type (let's call it int? ClassNumber), if the corresponding TextBox is empty (since it's not required), an exception is thrown by the ODS since it tries to convert an empty string value to an integer value before trying to set the object's Property. Hah! If ODS was able to determine that the integer is in fact nullable, it should pass in a null value instead! But alas, it throws a System.IndexOutOfRangeException: "Index was outside the bounds of the array" error. And further down the stack: "Exception: is not a valid value for Int32". Hmmm. Since this is a FormView control, we don't have the ability to use a BoundField control with 2 very useful properties: NullDisplayText and ConvertEmptyStringToNull. It would be nice to tell ODS to enable sending null values from any control we want.

 

The above was posted originally here.  I used his clipping because it describes perfectly the problem I had, along with many, many others. 

After hours and hours of Googling and trial and error I finally found the solution to this.  There was no way in hell I was going to accept the solution of manually re-populating each field I had bound in my edit and insert templates for my FormView.  The solution was much easier and left all of the heavy lifting to the FormView.

Basically, all you have to do is all insert and update parameters in your ObjectDataSource for each field you're binding.  For these fields, you just need to supply the field name, the data type and set the ConvertEmptyStringToNull property to TRUE.  Also, you'll need to be sure to set the ConvertNullToDBNul property to TRUE in the ObjectDataSource itself, like below. 

<InsertParameters>
<asp:Parameter Name="TimeZoneOffset" Type="int32" ConvertEmptyStringToNull="true" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="TimeZoneOffset" Type="int32" ConvertEmptyStringToNull="true" />
</UpdateParameters> 

 
So just by adding these parameters for the insert and update you can have your FormView's databinding work with nullable types.  Not too bad, huh?

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: ASP.NET
Posted by Don on Sunday, July 15, 2007
Permalink | Comments (21) | Post RSSRSS comment feed

FormView not retaining values when server-side validation fails

I recently spent quite a bit of time trying to figure out why my FormView wasn't retaining values after some of my custom server-side validation failed in my business logic layer.  I kept seeing that you just had to set KeepInEditMode = true (or KeepInInsertMode if you're doing an insert) and that would take care of it.

Well, after a lot of trial and error and hours googling and reading messages forums I finally found the answer.  Before I go into what I needed to do to fix it, I'll give a little bit of background.

I am using a FormView with an ObjectDataSource.  The ObjectDataSource maps to our business logic layer for the Select, Insert and Update methods.  Initially, the insert and update methods were returning an "envelope" object that contained a list of any BLL errors that were caught from server-side validation.

Everything worked fine using this approach except for retaining the values in the FormView that the user had changed before the last insert or update action.  I couldn't for the life of me figure out why the FormView kept re-initializing the data even though I didn't actually save anything to the DB in the BLL.

Well, it turns out that my approach of returning an envelope just wasn't cutting it.  What I had to do was throw an exception from the BLL class back to the calling page so that the FormView's ItemInserted and ItemUpdated events would keep the old data around.

Here's what I ended up with...

If Not e.Exception Is Nothing Then
     e.ExceptionHandled = True
     e.KeepInEditMode = True           
CType (Master, Site).ShowErrorPopup("Errors:", e.Exception.InnerException.Message) End If

If it doesn't see an exception, it thinks that the operation before (insert or update) was successful and it doesn't keep the old data around.  It goes and reinitializes the FormView with the select again.

So in my BLL I simple got rid of my envelope that I was passing back and built a new exception.  It's use is as follows:

Dim brokenRules As New StringBuilder
brokenRules = ValidationManager.ConsolidateBrokenRules(oneEntity.BrokenRulesList, brokenRules)
Throw New Common.EntityValidationException(brokenRules.ToString)

The new exception paired up with a class in the Master Page to display the errors to the user (via the AJAX Control Toolkit's Modal Popup Extender ) took care of my problems.

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: ASP.NET
Posted by Don on Friday, July 13, 2007
Permalink | Comments (4) | Post RSSRSS comment feed