Extension method vb.net vs c#
December 29, 2015
c#
////////////////
public static class Extensions { public static string GetFirstThreeCharacters(this String str) { if(str.Length < 3) { return str; } else { return str.Substring(0,3); } } }
vb.net
<System.Runtime.CompilerServices.Extension> _ Public Function GetFirstThreeCharacters(Byval str As String) As String If str.Length < 3 Then Return str Else Return str.Substring(0, 3) End If End Function
oop features in vb6
//////////////////////
http://cs.iupui.edu/~aharris/avb/avb4/oop.html
check oracle version
December 22, 2015
what is server version?
select * from v$version;
what is client version?
SELECT DISTINCT client_version FROM v$session_connect_info WHERE sid = sys_context('userenv', 'sid');
use String.Format in javascript like c#
January 11, 2015
// This is the function. String.prototype.format = function (args) { var str = this; return str.replace(String.prototype.format.regex, function(item) { var intVal = parseInt(item.substring(1, item.length - 1)); var replace; if (intVal >= 0) { replace = args[intVal]; } else if (intVal === -1) { replace = "{"; } else if (intVal === -2) { replace = "}"; } else { replace = ""; } return replace; }); }; String.prototype.format.regex = new RegExp("{-?[0-9]+}", "g"); // Sample usage. var str = "She {1} {0}{2} by the {0}{3}. {-1}^_^{-2}"; str = str.format(["sea", "sells", "shells", "shore"]); alert(str);
iis 8.5 issue inetpub do not have permission
September 19, 2014
OK, working from memory here as I am not in front of a Windows machine.
If you right click on your webroot folder /inetpub/wwwroot/ or the website directory you are working on open properties and select security, I think it is, you will see the list of users with their permissions for that folder. There is a section to add new users where you can add the IUSR account (search from the list of users if you need to) which will be the default user used when anonymous authentication is enabled. Give this account the relevant permissions (read, write, execute) ensuring you apply to file and subfolders. Refresh the website in IIS and you should hopefully be good to go.
dataset vs collection
October 30, 2013
- DataTable and DataSet are heavy weight comparitively using List Collection.
- List<Emp> enables you to maintain the safe type. So You no need to do typecasting anytime.
- It’s prefarable not to use DataSet and DataTable while your data is flowing between the layers as I mentioned in point1
- Java(any other than .NET languages) can not understand DataSet and DataTable while throwing from WebService or WCF. so it’s easy to convert the List<Emp> to Emp Array and throw it to Java. Java can understand simple clases and arrays.
Best practice – Dispose
October 26, 2013
Use built-in keyword in C# as a shortcut for this particular pattern of using
an IDisposable object and calling Dispose when it goes out of scope: the using
keyword
// Example use using (MyClass data = new MyClass()) { this.Store1.DataSource = data.getData(); this.Store1.DataBind(); } public class MyClass : IDisposable { private object resource1; // pointer for a resource private object resource2; // other resource you use private bool disposed = false; // implements IDisposable public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!this.disposed) { // if this is a dispose call dispose on all state you // hold, and take yourself off the Finalization queue. if (disposing) { if (resource1 != null) { ((IDisposable)resource1).Dispose(); resource1 = null; } if (resource2 != null) { ((IDisposable)resource2).Dispose(); resource2 = null; } } this.disposed = true; } } // finalizer simply calls Dispose(false) ~MyClass() { Dispose(false); }
…
Multiple Indexes vs Multi-Column Indexes
September 15, 2013
sql server optimize
September 15, 2013
Database Execution Plan
September 15, 2013
http://www.codeproject.com/Articles/9990/SQL-Tuning-Tutorial-Understanding-a-Database-Execu
คำสั่งลบ Execution plan และ cache ใน SQL Server
DBCC FREEPROCCACHE คือคำสั่งลบ Execution plan
DBCC DROPCLEANBUFFERS คือคำสั่งลบ cache ของผลการรัน SQL statement
ทั้ง 2 คำสั่งใช้ในสถาณการณ์ที่ต้องการ optimize คำสั่ง SQL ซึ่งระหว่างที่ทดลองปรับเปลี่ยน SQL เพื่อให้ได้ประสิทธิภาพมากที่สุด จำเป็นต้อง execute SQL หลายๆ ครั้ง ซึ่งหากไม่มีการ clear Execution plan หรือ cache ของการ execute ก่อน อาจจะทำให้การรันคำสั่งในครั้งถัดๆ มีความเร็วมากขึ้น ซึ่งทำให้เข้าใจผิดได้ว่า SQL นั่นให้ประสิทธิภาพที่ดีกว่าครับ
http://www.ruxcom.com/tag/sql-server