/// <summary> /// generate and inseret respondent data(ip, date) to the database using the respondent id /// </summary> /// <param name="r_id">provided by method call</param> /// <returns> returns true if success; else false </returns> public bool AddRespondent(int r_id) { DateTime today = DateTime.Today; Const cons = new Const(); try { using (SqlConnection conn = new SqlConnection(Const.DbConnStr)) { conn.Open(); SqlCommand addRespondent = conn.CreateCommand(); addRespondent.CommandText = "INSERT INTO dbo.Respondents(r_id,ip_ad,r_date) VALUES(@RID,@IP,@DATE)"; addRespondent.Parameters.AddWithValue("@RID", r_id); addRespondent.Parameters.AddWithValue("@IP", cons.GetIPAddress()); addRespondent.Parameters.AddWithValue("@DATE", today); addRespondent.ExecuteNonQuery(); return(true); } } catch (Exception e) { Console.WriteLine(e.Message); } return(false); }