Robin19's Profile User Rating: *****

Reputation: 267 Architect
Active Posts:
547 (0.37 per day)
07-July 10
Profile Views:
Last Active:
User is offline Jul 25 2014 01:58 PM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
Expert In:

Latest Visitors

Icon   Robin19 has not set their status

Posts I've Made

  1. In Topic: Asynchronous call from view

    Posted 18 Jul 2014

    An async method means the method will return later. This works well in a WPF environment like your tutorial. This doesn't work well when a web server is trying to deliver a page. Your web server needs to take the cshtml and turn it into a text file to deliver. That is the nature of the internet. The server has trouble doing that when the cshtml says "I'll get back to you". I can think of two ways around this.

    Put your async call in the controller. The controller will need to await the async function to finish. This syncronizes the function and could cause a time-out if the async call takes too long.

    Use AJAX. The A stands for Async, which kind of hints at this being a possible solution.
  2. In Topic: Who has worked with/written software that runs in automobiles?

    Posted 27 Jun 2014

    There is still a worry about effecting the engine stuff. The control systems all talk to each other. A coworker helped me jump my car last year. The first time he plugged it in he had it wrong. I started having odd behavior from the car a couple of months later. Things not running when they were supposed to or turning off for no reason, including the engine. It ended up that the lights controller had been fried and the bios was bad. That controller would misinterpret signals and send bad signals back though the bus. These signals would sometimes get interpreted by the other controllers to do something. The car repairman had to wipe the memory and re-install the factory image of six of them to get them talking to each other correctly.
  3. In Topic: Cannot get form width and height to size

    Posted 24 Jun 2014

    Put your cursor on "InitializeComponent" and hit F12 (or right click and select "Go to Definition"). This method is where all of your controls (and their properties) get set. This code is auto-generated from the WYSIWYG view of your class. Do not edit this partial class since it will be erased and created again whenever you change something in the WYSIWYG editor. So none of your controls have been created until you call that method. Always do work after that method call.

    It is possible to do all of this by hand and not call the InitializeComponent, but it is a pain in the butt. I used to do Java and had to do all of those calls by hand. I'm glad to be in VS now.
  4. In Topic: complicated Delete button

    Posted 23 Jun 2014

    You can use a SqlCommand object and call ExecuteNonQuery between opening and closing the connection.

    Other non-solicited advice:
    Move these statements into a different methods than the event handler. Even better is to have them in their own class so they are no longer tied to your GUI. Then you can test them on their own or move the logic to a different GUI framework.

    Don't use string concatenation to create your Sql statement. Use Parameters to prevent Sql Injection. It also makes it easier for a human to read the statement and see where errors might be hiding (like missing quote marks).

    The SqlConnection object needs to be cleaned up when you are done with it. Either re-create it each time you use it or make sure you dispose of the SqlConnection object in your Dispose method. The SqlCommand object will need the same treatment.

    public class PhoneBookDAL
       private readonly string connString;
       public PhoneBookDAL(string connString)
          this.connString = connString;
       private int SafelyRun(SqlCommand command)
          SqlConnection connection = null;
             connection = command.connection;
             var rowsChanged = command.ExecuteNonQuery();
             return rowsChanged;
             if (connection != null && connection.State == ConnectionState.Open)
       public int Delete(string name)
          using(var connection = new SqlConnection(this.connString))
             using(var command = new SqlCommand())
                command.Connection = connection;
                command.Statement = "Delete from tbPeople where Name='@name'";
                command.Parameters.Add("@name", SqlDbType.NChar, 50).Value = name;
  5. In Topic: Is there a need to seporate WPF and Winform threads?

    Posted 18 Jun 2014

    There are also a lot of "I'm just learning C# and have a problem..." questions that get asked. They don't always come out and say that but we can sometimes guess by their question. We suggest they use the latest (greatest?) if you are just learning. I don't think many people start learning English by studying Chaucer and Shakespeare. You wait until you understand the modern language before learning the old stuff.

    Edit: And only learn the old stuff if you really have to. I slept through all of my Chaucer and Shakespeare blocks.

My Information

Member Title:
D.I.C Addict
Age Unknown
June 15
Programming Languages:
C#, Java, C++, VB.NET, WPF, XNA

Contact Information

Click here to e-mail me



Page 1 of 1
  1. Photo

    ni44ko Icon

    23 Nov 2010 - 19:19
    thanks. i want to be your apprentice.
Page 1 of 1