MrShoes's Profile User Rating: -----

Reputation: 314 Architect
Active Posts:
496 (0.5 per day)
13-June 12
Profile Views:
Last Active:
User is offline Feb 23 2015 05:18 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:
Expert In:
Icon   MrShoes .Status == null

Posts I've Made

  1. In Topic: CRUD update - right direction? - suggestions

    Posted 17 Feb 2015

    Two comments:
    • There's no point in having two catches that do the same thing, since the SqlException would also be caught as an Exception.
    • If you wrap the connection object in a using block, it will be closed and disposed automatically.

    The using block thing is really neat. You could shorten code to:
    public static void CreateProduct(Product product)
                using(var connection = new SqlConnection(connectionstring))
                string createStatement = "INSERT INTO [dbo].[Products](ProductName, ProductPrice, ProductType) " +
                    "VALUES(@ProductName, @ProductPrice, @ProductType)";
                SqlCommand createCommand = new SqlCommand(createStatement, connection);
                createCommand.Parameters.AddWithValue("@ProductName", product.ProductName);
                createCommand.Parameters.AddWithValue("@ProductPrice", product.ProductPrice);
                createCommand.Parameters.AddWithValue("@ProductType", product.ProductType);
                catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

    You can do the same with a Reader too, to make your code even more concise.
  2. In Topic: How to select an open application window using c#

    Posted 10 Feb 2015

    I shouldn't think there's any .NET way of handling that... after all, the windows might not belong to .NET applications. I'd guess you'd have to use P/Invoke, how comfortable are you with that? Try the EnumWindows function...
  3. In Topic: Issue with SQLite

    Posted 23 Jan 2015

    Oh yeah, I remember now from working with SQLite in the past. There should be 2 versions of the interop file, one in a folder "x64" and one in "x86". Are they visible in Solution Explorer (you may need to select the project and then click the "Show All Files" button)? Make sure their Build Action is "Content", and they're set to "Copy if newer" or "Copy Always".
  4. In Topic: Issue with SQLite

    Posted 23 Jan 2015

    Trying to load a DLL built for x64 in x86 (and vice versa) throws a System.InvalidFormatException in my experience, so I don't think it's that. The issue indicates the file can't be loaded, which is usually because it's not where it's expected. In Solution Explorer, check the SQLite interop DLL in References, and check the Path property. If the file isn't at that path, that's the problem.
  5. In Topic: How do i use encapsulation, polymorphism and inheritance in C# WPF

    Posted 21 Oct 2014

    In fact, even in using .NET and WPF you can't avoid using these concepts. All .NET framework objects inherit. All use encapsulation. All use polymorphism. Even if you're not directly using these concepts in your design, you are at the very least using objects that do.

    I wonder if your question is more aimed at XAML: well, you might not realise this, but all the XAML does is instantiate .NET objects and renders them at certain points. It is not quite as obvious at first glance though. Even when you create a page, you are writing a class that inherits from Page, then you are instantiating it when used. It's different syntax, but certainly relies on OOP concepts.

My Information

Member Title:
D.I.C Regular
Age Unknown
December 19
United Kingdom
Full Name:
Ian Hughes
Programming Languages:
C, C++, C#, JavaScript, WPF, XAML, HTML, SQL, SAS, BASIC

Contact Information



Page 1 of 1
  1. Photo

    Michael26 Icon

    19 Jul 2013 - 23:16
    Congrats on promotion.
Page 1 of 1