Database Reference
In-Depth Information
cmd.ExecuteNonQuery();
lblInsertStatus.Text = "New Currency Added Successfully!!";
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message + ex.StackTrace, "Exception Details");
}
finally
{
conn.Close();
}
}
15. To set the CommandReader form as the start-up form, modify the Program.cs
statement:
Application.Run(new CommandReader ());
to appear as :
Application.Run(new CommandNonQuery());
Build the project, and run it by pressing Ctrl+F5.
16. When the form loads and you are ready to enter currency details, you need to
be careful because the table Sales.Currency used in the exercise has the
column CurrencyCode defined as a primary key. Hence, if you try entering a
currency that might already exist in the table (which will be the case when you
try entering most of the well-known currencies), then you will get a primary
key violation. For example, when you try to enter USD as the currency code,
the moment you click the button Insert Currency, an exception occurs, as
shown in Figure 13-9.
Search WWH ::




Custom Search