Given the following code ....
string sVal = (reader.IsDBNull(i)) ? "null" : ObjectToSQLString(objs[i]);
static string ObjectToSQLString(object o) { if (o == null || o == DBNull.Value) return "null";
Type t = o.GetType();
if (t == typeof(string)) return string.Format("'{0}'", ((string)o).Trim().Replace("'", "''")); if (t == typeof(int)) return ((int)o).ToString(); if (t == typeof(Int16)) return ((Int16)o).ToString(); if (t == typeof(long)) return ((long)o).ToString(); if (t == typeof(float)) return ((float)o).ToString(); if (t == typeof(double)) return ((double)o).ToString(); if (t == typeof(bool)) return ((bool)o).ToString(); if (t == typeof(DateTime)) return string.Format("'{0}'", ((DateTime)o));
throw new DataException(); }
any chance of an explanation of the line
Thanks