For postgres, you also need to replace "\" public string escape (string s) { s = s.Replace("\\", "\\\\"); // Replace \ with \\ s = s.Replace("\'", "\'\'"); // Replace ' with '' (SQL Standard) //s = s.Replace("\"", "\\\""); not necessary if enclosed in single quotes. return s; } Howard Cole www.selestial.com