# Sunday, January 08, 2006

If you try to run a CREATE statement in a query (right click on a database in the Server Explorer) you receive this message.

So i wrote a small utility which will do the job for me.

using System;

using System.IO;

using System.Data.SqlClient;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

 

namespace MdfExec

{

    class Program

    {

        static void Main(string[] args)

        {

            string _cnStr;

 

            if (args.Length == 2)

            {

                _cnStr =

                    "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +

                    "AttachDBFilename=" + args[1] + ";User Instance=true;";

            }

            else

            {

                OpenFileDialog fd = new OpenFileDialog();

 

                fd.AddExtension = true;

                fd.DefaultExt = ".mdf";

                fd.ShowDialog();

 

                _cnStr =

                    "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +

                    "AttachDBFilename=" + fd.FileName + ";User Instance=true;";

            }

 

            using (SqlConnection _cn = new SqlConnection(_cnStr))

            {

            using(SqlCommand _cmd = _cn.CreateCommand())

                   {

                    using (StreamReader fs = File.OpenText(args[0]))

                    {

                        _cmd.CommandText = fs.ReadToEnd();

                        _cmd.Connection.Open();

                        _cmd.ExecuteNonQuery();

                    }

                   }

            }

        }

    }

}

 

You can now right click on a *.sql file choose "open with ..." and select MdfExec.exe to execute the SQL statement.

Since there is no second parameter (but needed to define to which database to connect) a OpenFileDialog will prompt:

 

Happy coding

Sunday, January 08, 2006 3:31:55 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 

I'm quite busy with a project I'm on with Clemens (the last before he'll join the Indigo team at Microsoft) - just to explain why it got bit quiet around me :-)

Here is a modified version of the prop snippet that I want to share ( and remember :-P ).

<?xml version="1.0" encoding="utf-8" ?>

<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

      <CodeSnippet Format="1.0.0">

            <Header>

                  <Title>prop</Title>

                  <Shortcut>prop</Shortcut>

                  <Description>Code snippet for property and

                  backing field</Description>

                  <Author>Microsoft Corporation</Author>

                  <SnippetTypes>

                        <SnippetType>Expansion</SnippetType>

                  </SnippetTypes>

            </Header>

            <Snippet>

                  <Declarations>

                        <Literal>

                             <ID>type</ID>

                              <ToolTip>Property type</ToolTip>

                             <Default>int</Default>

                        </Literal>

                        <Literal>

                             <ID>property</ID>

                             <ToolTip>Property name</ToolTip>

                             <Default>MyProperty</Default>

                        </Literal>

                        <Literal>

                             <ID>field</ID>

                             <ToolTip>The variable backing this

                             property</ToolTip>

                             <Default>myVar</Default>

                        </Literal>

                  </Declarations>

                  <Code Language="csharp"><![CDATA[#region $property$

     

      // This field holds the $property$

      private $type$ $field$;

 

      /// <summary>Gets/sets the $property$.</summary>

      /// <value>A <see cref="$type$">$type$</see>

      /// containing the $property$.</value>

      /// <remarks>This property gets/sets the $property$.</remarks>

      [System.ComponentModel.Description("Gets/sets the $property$.")]

      public $type$ $property$

      {

            get { return $field$;}

            set { $field$ = value;}

      }

      #endregion

      $end$]]>

                  </Code>

            </Snippet>

      </CodeSnippet>

</CodeSnippets>

Sunday, January 08, 2006 2:54:09 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, December 23, 2005

Friday, December 23, 2005 11:19:04 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, December 18, 2005

I just finished writing some ASP.NET code where I also typed the following lines: 

 <ItemTemplate>
	<asp:Image ID="IsOnline" 
	runat="server" 
	ImageUrl='<%# GetImageUrl((MembershipUser)Container.DataItem) %>' 
	/>
</ItemTemplate>

...

protected string GetImageUrl(MembershipUser user)
{
	if (user.IsLockedOut)
	{
		return "~/images/BadUser.gif";
	}
	else if (!user.IsApproved)
	{
		return "~/images/GreyUser.gif";
	}
	else if (user.IsOnline)
	{
		return "~/images/OnlineUser.gif";
	}
	else
	{
		return "~/images/OfflineUser.gif";
	}
}

Before I shutdown my machine I fetchted Mail and Feeds when i ran accross this posting by ScottGu pointing to Fritz Onions Blog.

;-)

Sunday, December 18, 2005 12:59:36 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, December 15, 2005

No Comment :-P

Thursday, December 15, 2005 10:41:59 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, December 13, 2005

Michael Willers, our security expert, just pointed me to an interesting resource related to ASP.NET Security.

Tuesday, December 13, 2005 10:24:23 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [3]  | 
# Friday, December 09, 2005

[Via Peter]
SnippyDarren May found this cool little client app for creating VS2005 code snippets. And to think I’ve been doing them by hand all this time…
[...]

Friday, December 09, 2005 10:20:54 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, December 08, 2005

Jonathan Cogley has posted a nice piece of javascript: http://weblogs.asp.net/jcogley/archive/2005/12/07/432584.aspx

ASATISMT (As Soon As There Is Some More Time) I need to wrap smth like this with a control...

Thursday, December 08, 2005 10:13:58 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 

Yesterday the new issue of the MSDN Magazine Europe arrived in our office. It includes my article about my travel to the DDD Developer Day in Reading.

Thursday, December 08, 2005 9:50:30 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [6]  | 
# Friday, November 11, 2005

Friday night Andreas Hoffmann (2nd lead of the VfL-NiederRhein user group) picked me up ad we drove the long way down to the south.

 

Our destination for Saturday morning was the “Chaostage” event of the .NET user group Deggendorf  (http://dotnet-deggendorf.sefnet.de/). I had a session “Introducing the concepts and architecture of ASP.NET“ in the morning and a second one “Hello WebServices – Message-Oriented Programming for distributed systems” in the evening.



We checked in at our hotel in Garching (I won’t tell the name but I’ll tell you a bit about the worst service). Because the waitress served me frozen potatoes with my steak I stood up and walked over to the bar. Just in this moment a voice behind me asked “Is this a codezone keychain? Are you gonna be at Microsoft on Monday?” It was Nicki Wruck (http://spaces.msn.com/members/icebloginfo/PersonalSpace.aspx) the organizer of the ICE 2005 Community together with Frank Solinske (http://spaces.msn.com/members/solinske/PersonalSpace.aspx) IT-Pro Security Guru. Only one nano-second later we drank the first beer together. The geek meet was so exciting that I was just about to forget the bad service of our hotel J

Sunday we fetched Stephan Oetzel (http://stephanon.net/) in Poing. We picked up Michael Willers (http://www.staff.newtelligence.net/michaelw/) Developer Security Guru from the Airport to merge the Security guys in the “Hofbräukeller”. Uwe Baumann (http://blogs.msdn.com/uweinside/) discussed about technical stuff with Andreas and me meanwhile. Later Nicki joined us together with Nico Lüdemann (https://www.openbc.com/hp/Nico_Luedemann/) and Carola Helfert (https://www.openbc.com/hp/Carola_Helfert/).

Monday - Launch Day – started with the Community GetTogether. Stephan and Andreas and I presented the results of the .NET Summit NRW (our community event). As always the time to do some “networking” was toooooooo short - even if we had at least the day before to talk to a few guys. The Launch Party was great. Steve Balmer’s Launch talk was transmitted per satellite into the Lobby of Microsoft in Germany – Great. The only problem again: So many people and such a small amount of time :-) 

Friday, November 11, 2005 9:53:42 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |