Answers
Sep 25, 2008 - 06:39 AM
Using SQL Management Studio Express, open the database and table you're working with. If you will highlight the "date" column and look at the properties (usually displayed below the table designer) you will see a property for "Default Value".
Enter "getDate()" into that default value column and it will automatically set the current system timestamp into the database.
Alternatively, you could add a parameter to your insert statement that would add the date in as well.
SqlConnection cn = new SqlConnection("YourConnectionString");
SqlCommand cmd = new SqlCommand("InsertRecord", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UserID", SqlDbType.Decimal).Value = userID;
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Now;
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
The way to automatically email folks could be done with a Windows Service or perhaps a scheduled job. For the scheduled job you'll need to consider Windows Script Host or whatever is the current replacement. I prefer to use the service approach.
Let me know if there's anything else I can do to help you on the way.
Take care,
Ric
Mar 24, 2009 - 06:49 AM
The Quomon Team
Add New Comment