public void LogCalltoDB(string technicianName, string territory, string emBod, string date, string callCategory) { string connectionString = ConfigurationSettings.AppSettings["Inventory2"].ToString(); SqlConnection myCon = new SqlConnection(connectionString); SqlCommand myCommand = new SqlCommand("INSERT INTO CallTracker(techName, territoryID, problem, date, problemCategory) VALUES(@technicianName, @territory, @emBod, @date, @callCategory)", myCon); myCommand.Parameters.Add(new SqlParameter("@technicianName", technicianName)); myCommand.Parameters.Add(new SqlParameter("@territory", territory)); myCommand.Parameters.Add(new SqlParameter("@emBod", emBod)); myCommand.Parameters.Add(new SqlParameter("@date", date)); myCommand.Parameters.Add(new SqlParameter("@callCategory", callCategory)); myCon.Open(); myCommand.ExecuteNonQuery(); myCon.Close(); }
try { this.callTrackerTableAdapter.FillByTerritory(this.inventory2DataSet.CallTracker, new System.Nullable<int>(((int)(System.Convert.ChangeType(terrCallTextBox.Text,typeof(int)))))); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); }