Database Reference
In-Depth Information
cmd.Parameters.Add(new SqlParameter("currCode", SqlDbType.NVarChar, 3));
cmd.Parameters["currCode"].Value = lstCurrency.SelectedItem.ToString();
try
{
// Open connection
conn.Open();
// Delete Query
if (lstCurrency.SelectedIndex == -1)
{
MessageBox.Show("Please Select a Currency before performing Delete
action",
"Information");
}
else
{
cmd.ExecuteNonQuery();
lblDeleteStatus.Text = "Currency is Deleted Successfully!!";
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message + ex.StackTrace, "Exception Details");
}
catch (NullReferenceException ex)
{
MessageBox.Show("Load the Currency List first" + ex.StackTrace, "Exception
Details");
}
finally
{
conn.Close();
}
}
11. To set the CommandStoredProcedure form as the start-up form, modify the
Program.cs statement.
Application.Run(new CommandNonQuery ());
to appear as :
Application.Run(new CommandStoredProcedure());
Build the project, and run it by pressing Ctrl+F5.
12. When the form loads, click the Button control called Load Currency List first;
this will load the currencies from the Sales.Currency table.
13. Now, select a currency (the one that you have not added), and click the Delete
Currency button. As you may remember, the Sales.Currency table uses
CurrencyCode as a primary key, so this key column is referenced by the
 
Search WWH ::




Custom Search