Q:

C# .Net3.5 adding data to a SQL Server 2005 database if it dosn't already exist and if it does update it?

Hi now playing with SQL for the first time!
I have the code below which works fine but I need to check if the entry is already in the database using CustomerName and Product to match on and if it is in the database update the other fields and if not insert all the data. 
How would I do this?
Below is the code I use to insert a new record:
DateTime FirstDateSeen = new DateTime();
FirstDateSeen = DateTime.Now.Date;

DateTime LastDateSeen = new DateTime();
LastDateSeen = DateTime.Now.Date;

SqlConnectionStringBuilder MySqlConnection = new SqlConnectionStringBuilder("MY CONNECTION");
SqlConnection db = new SqlConnection(MySqlConnection.ToString());

try //sql string for first seen
{
   string sqlIns = "INSERT INTO Customer (Product, Version, CustomerName, CustomerPostcode,  FirstSeen, LastSeen)" +
   "VALUES (@Product, @Version, @CustomerName, @CustomerPostcode, @FirstSeen, @LastSeen)";

   db.Open();
   SqlCommand cmdIns = new SqlCommand(sqlIns, db);
   cmdIns.Parameters.Add("@CustomerName", UniqueA);
   cmdIns.Parameters.Add("@Product", AppName);
   cmdIns.Parameters.Add("@Version", AppVer);
   cmdIns.Parameters.Add("@CustomerPostcode", UniqueB);
   cmdIns.Parameters.Add("@FirstSeen", FirstDateSeen.ToShortDateString());
   cmdIns.Parameters.Add("@LastSeen", LastDateSeen.ToShortDateString());
   cmdIns.ExecuteNonQuery();

   cmdIns.Parameters.Clear();
   cmdIns.Dispose();
   cmdIns = null;
}
catch (Exception ex)
{
   throw new Exception(ex.ToString(), ex);
}
finally
{
   db.Close();
}

A:

IF EXISTS(SELECT CustomerName FROM Customer WHERE CustomerName = @CustomerName)
BEGIN
   UPDATE Customer ..
END
ELSE
BEGIN 
    INSERT INTO Customer (Product, Version, CustomerName, CustomerPostcode,  FirstSeen, LastSeen)  
    VALUES (@Product, @Version, @CustomerName, @CustomerPostcode, @FirstSeen, @LastSeen)
END

Lots of other fun stuff going on here...
Here is one pointer
catch (Exception ex)
{
   throw new Exception(ex.ToString(), ex);
}

is better as
catch (Exception ex)
{
   // do stuff
   throw;
}

or
catch ()
{
   throw;
}

