The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,721 other followers

Archive for August 28th, 2013

On Windows: Do not install the Android SDK ADT bundle in a path with spaces

Posted by jpluimers on 2013/08/28

Some 20 years after someone thought it was a nice idea to allow spaces in path names on Windows, it still is a bad idea to rely that just “works” for everything.

Today I tried to see if it still applied what I mentioned 2 years ago during the German BASTA! Fall conference in the Rheingoldhalle when talking about cross platform .NET development using MonoDroid/MonoTouch/Visual Studio:

Android SDK
http://developer.android.com/sdk/index.html
– Windows:
- http://dl.google.com/android/installer_r13-windows.exe
- http://dl.google.com/android/android-sdk_r13-windows.zip
Do not install in a directory with spaces (not C:\Program Files, but C:\android-sdk)

And it does still apply: though not mentioned in the Android SDK/ADT documentation, most of the batch files in the Android SDK ADT bundle are not compatible being stored in a path that has spaces.

Unquoted referrals to paths like this are used in most SDK batch files:

cd /d %~dp0

The only way to run these batch files is with the current directory being the directory of the batch file itself, or referring to them in their fully quoted form.

Another correct way would be to use short names, but that’s only done in find_java.bat:

%~dps0

Summary of the batch files and how they are affected:

(Side note: most incompatible batch files correctly do `for %%i in (“%cd%”) do set prog_dir=%%~fsi`)

So: make sure “…”  is a path not containing spaces.

–jeroen

Posted in Android, BASTA!, Conferences, Development, Event, Mobile Development, Software Development | Tagged: , , , , , , , | Leave a Comment »

.NET/C#: extension method shows what SQL + parameter values are sent to the server (via StackOverwlow)

Posted by jpluimers on 2013/08/28

Every once in a while you are in situation where you are not allowed to use SQL Server Profiler, nor to see any query plans, but you still want see the SQL going from your .NET apps to the database server.

With that SQL, you can feed it through your favourite database tool, and see where the culprit is.

There are various ways of getting rudimentary or a bit more advanced SQL out of this. Flapper posted a solution that is specific for SQL Server (and requries both ObjectExtensions.cs and StringExtensions.cs from the DotNetX library), but posted more ready to use SQL.

I opted – and wanted to hank Justin Harris – for this piece of code on StackOverflow, which works on any IDbCommand (so you can use it for any ADO.NET data provider, like SQL Server, OLE DB, Oracle, etc):

While you will not be able to plug is into something like Enterprise Manager to run it works for logging.

public static string ToReadableString(this IDbCommand command)
{
    StringBuilder builder = new StringBuilder();
    if (command.CommandType == CommandType.StoredProcedure)
        builder.AppendLine("Stored procedure: " + command.CommandText);
    else
        builder.AppendLine("Sql command: " + command.CommandText);
    if (command.Parameters.Count > 0)
        builder.AppendLine("With the following parameters.");
    foreach (IDataParameter param in command.Parameters)
    {
        builder.AppendFormat(
            "     Paramater {0}: {1}",
            param.ParameterName,
            (param.Value == null ?
            "NULL" : param.Value.ToString())).AppendLine();
    }
    return builder.ToString();
}

answered Apr 12 ’10 at 20:26; juharr

You saved my day! Not being allowed to use the profiler, this is a great way to get the actual SQL, then run it from SSMS or the Enterprise Manager. – Jeroen Wiert Pluimers

I pasted it in a DataExtensions class like this: Read the rest of this entry »

Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

 
%d bloggers like this: