Así que veremos otra alternativa a esto de arriba claro cuando necesitemos que un parámetro del WHERE sea dinámico.
Básicamente jugamos con el parámetro de entro en un AND usando un OR para las opciones
public static string GetShortFileName(string fileDirectory, string fileNameWithExtension) { StringBuilder temp = new StringBuilder(255); string path = System.IO.Path.Combine(fileDirectory, fileNameWithExtension); int n = GetShortPathName(path, temp, 255); if (n == 0) throw new NotImplementedException(); string extension = System.IO.Path.GetExtension(path); return ((temp.ToString().Split('\\')).Last()).ToLower();//.Replace(extension, string.Empty); } [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)] public static extern int GetShortPathName( [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPTStr)] string path, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
string nomFile = GetShortFileName(Path.GetDirectoryName(FilePath), Path.GetFileName(FilePath)); nomFile = nomFile.Substring(0, nomFile.Length - 4); OleDbDataAdapter dadp = new OleDbDataAdapter("select * from [" + nomFile + "#DBF];", con);
"La verdad nos hará libres"
protected string RenderPartialViewToString(string viewName, object model) { if (string.IsNullOrEmpty(viewName)) viewName = ControllerContext.RouteData.GetRequiredString("action"); ViewData.Model = model; using (StringWriter sw = new StringWriter()) { ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName); ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw); viewResult.View.Render(viewContext, sw); return sw.GetStringBuilder().ToString(); } }
function are_cookies_enabled() { var cookieEnabled = (navigator.cookieEnabled) ? true : false; if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { document.cookie = "testcookie"; cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false; } return (cookieEnabled); }También se puede saber creando una cookie y comprobar si el navegador lo hizo o no.
object o = new { valor1 = "", valor2 = "", valor3 = "" };
Type t = o.GetType(); ProcessInfo p = t.GetProperty("valor1"); object v = p.GetValue(t);
Type t = o.GetType(); object v = t.GetProperty("valor1").GetValue(t);