Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1513)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1514)
@@ -961,5 +961,5 @@
             string sLen = sp.TotalMinutes.ToString();
             string sPatID = rApptInfo.PatientID.ToString();
-            string sNote = rApptInfo.Note;
+            string sNote = stripC30C31(rApptInfo.Note);
             string sResource = rApptInfo.Resource;
 
@@ -1004,4 +1004,24 @@
         }
 
+        /// <summary>
+        /// Replaces ascii 30 and 31 as they are used as delimiters. Funny users can crash the program.
+        /// </summary>
+        /// <param name="s">Input String</param>
+        /// <returns>Output Stripped String</returns>
+        public string stripC30C31(string s)
+        {
+            if (s != null && s.Length > 0)
+            {
+                System.Text.StringBuilder sb = new System.Text.StringBuilder(s.Length);
+                foreach (char c in s)
+                {
+                    sb.Append(((c==30)||(c==31)) ? ' ' : c);
+                }
+                s = sb.ToString();
+            }
+
+            return s;
+        }
+
         public void EditAppointment(CGAppointment pAppt, string sNote)
         {
@@ -1009,5 +1029,5 @@
             {
                 int nApptID = pAppt.AppointmentKey;
-                string sSql = "BSDX EDIT APPOINTMENT^" + nApptID.ToString() + "^" + sNote;
+                string sSql = "BSDX EDIT APPOINTMENT^" + nApptID.ToString() + "^" + stripC30C31(sNote);
 
                 System.Data.DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "EditAppointment");
