inspiration

Leave a comment

Extension method vb.net vs c#

Leave a comment

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

https://books.google.co.th/books?id=kVqB5hjNsScC&pg=PA345&lpg=PA345&dq=visual+basic+6+oop&source=bl&ots=19WwyyRM-D&sig=sC5sSwF-kfDbTW5NIKu8oAd3mHI&hl=en&sa=X&ved=0ahUKEwjtqrHMp5HKAhXECo4KHbkIB4cQ6AEIVTAJ#v=onepage&q=visual%20basic%206%20oop&f=false

check oracle version

Leave a comment

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#

Leave a comment

// 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

Leave a comment

http://stackoverflow.com/questions/8232922/asp-pages-in-iis-using-localhost-401-3-error-do-not-have-permission

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

Leave a comment

  • 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

Leave a comment

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);
        }

Older Entries