7 dec 2011

convert object to insert query or Create table statement

Okey I know, the code represented here is not the code that you want to use for the CRUD in an ERP system. bud sometimes things need to go fast.



example

string insertquery = Myobject.ToSqlQuery();


put these functions in a public static class file:

  public static string ToSqlQuery(this T primary)
        {
            int counter = 0;
            string Columnstatement = "INSERT INTO " + typeof(T).Name + "  (";
            string ValueStatement = " VALUES ( ";
            foreach (var pi in typeof(T).GetProperties())
            {

                string priValue = string.Empty;
                PropertyInfo pil = (PropertyInfo)pi;
                try
                {
                    priValue = pi.GetGetMethod().Invoke(primary, null).ToString();
                }
                catch (Exception)
                {
                                    
                }


                if (priValue != string.Empty)
                {
                    if (counter > 0)
                    {
                        ValueStatement += ",";
                        Columnstatement += ",";
                    }
                    Columnstatement += "[" + pil.Name + "]";
                    ValueStatement += "'" + priValue + "'";
                    counter++;
                }
              
                                    
            }

            return Columnstatement + ") " + ValueStatement + ")";
        }




 
        public static string ToSqlCreateTable(this T primary)
        {
            int counter = 0;
            string Columnstatement = "CREATE TABLE " + "TABLENAME  (";
            string ValueStatement = "VALUES ( ";
            foreach (var pi in typeof(T).GetProperties())
            {
                PropertyInfo pil = (PropertyInfo)pi;
                if (counter > 0)
                {
                    Columnstatement += ",";
                }
                Columnstatement += "[" + pil.Name + "]" + "  VARCHAR(254)";
                counter++;
            }
            Columnstatement += ")";
            return Columnstatement;
        }

6 dec 2011

recovering from a disconnected citrix session

when a user is disconnected from a citrix session, its difficult to connect back to the same session.

first set all other citrix servers "log on to this server" off.
and let the user login again. with some luck it will connecting to the right connection


if this doesnt work open the profile of the user and look for the xar file for excel file recovery

Drive:\Documents and Settings\user_name\Application Data\Microsoft\Excel

2 dec 2011

windows xp : wrong routing with pptp VPN

  1. Start => run => regedit
  2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\
  3. open the  element "Bind"
  4. place the value  "\Device\NdisWanIp" and copy this on the top of the list.

connect to active directory with oledbconnection


connectionstring
Provider='ADsDSOObject'
query
;(&(objectClass=user)(objectCategory=person));distinguishedName,mobile,pager;SubTree

ramdisk

you dont have the money for a SSD disk but you need fast acces to some files?




http://memory.dataram.com/products-and-services/software/ramdisk

22 nov 2011