Friday, December 21, 2012

Get List Of Processes Using A DLL

here

Appending case to varchar in select

make sure you have an "else";otherwise you will append in some cases a null which will blot out the select

Thursday, December 20, 2012

Datatable Merge

if the schema is the same it will work as a union , if it has a different schema then that depends on

for e.g.


            DataTable t1 = new DataTable();
            t1.Columns.Add("key1");
            t1.Columns.Add("c1");
            t1.PrimaryKey = new[] { t1.Columns["key1"] };
            t1.Rows.Add(1, "data1");

            DataTable t2 = new DataTable();
            t2.Columns.Add("key1");
            t2.Columns.Add("c2");
            t2.PrimaryKey = new[] { t2.Columns["key1"] };
            t2.Rows.Add(1, "data2");

            t1.Merge(t2, false, MissingSchemaAction.Add);
            t1.Merge(t2);
             
            will produce
         
           while 

            DataTable t3 = t1.Clone();
            t3.Rows.Add("key2", "datablah", "datablah2"); 
            t1.Merge(t3);
            
           will produce


Implicitly Typed Arrays

Implicitly Typed Arrays


Array of Bytes to File


easy method  

   using (System.IO.FileStream _FileStream = new System.IO.FileStream(@"C:\blah\blah.csv", System.IO.FileMode.Create, System.IO.FileAccess.Write))
           {
               _FileStream.Write(bytesarray, 0, bytesarray.Length);
               _FileStream.Close();
           }

Wednesday, December 19, 2012

Killing a process

with taskkill

Using VS for file compare

right click on any file ->compare ->choose 2 local files to compare


thus:


The maximum array length quota (NNNN) has been exceeded

add readerquotas to binding

<readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxNameTableCharCount="2147483647" />

Monday, December 10, 2012

to avoid The site's security certificate is not trusted! errors

use this in Global aspx


  void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            System.Net.ServicePointManager.ServerCertificateValidationCallback =
                ((certSender, certificate, chain, sslPolicyErrors) => true);
        }

of course , this is where there is no security issue

IE9

Good article

Would you like to make Internet Explorer your default browser?

setting don't ask again does not work

Wednesday, December 5, 2012

Limiting file size of uploads in IIS

maxRequestLength indicates the maximum request size supported by ASP.NET
measured in KB
<httpRuntime executionTimeout="900" maxRequestLength="1048576"/>

maxAllowedContentLength specifies the maximum length of content in a request supported by IIS.
measured in bytes
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576000" />

Tuesday, December 4, 2012

Excel-CSV Date Issues



What happens when you save the following s/sh to csv?


The first column is formatted mm-dd-yyyy  (jan-2 ), the second dd-mm-yyyy(feb-12 )

The answer: 12-02-2011,12-02-2011

Linq issues with datatables

first the interesting thing
if a linq query returns an empty array of datarows - you can still run tolist() on the object.
a different issue that sidetracked me for a long time - if you do something like 


row.Field<string>("BLAH").ToLower()
this will fail if null

Wednesday, November 28, 2012

Could not load file or assembly 'blah'

or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.


I had this with a WCF service in which there were 2 dll's in the bin  , 1 a backup copy of the other.


At a later date I had this when there was some kind of conflict with supporting dll's so I just comepletely deleted the bin and got the supporting dll's from my development bin

IP to machine name




C:\>nbtstat -a n.n.n.n


Monday, November 26, 2012

'RSClientController' is undefined

I had to change the app pool managed pipeline to classic

Unformattable dates in s/sh gear and excel

if you enter a value such as "123456789" in excel and format it to a date - excel cannot show it so it displays "######################". If you save to csv , excel will save "######################". spreadsheetgear will save nothing to csv.

Tuesday, November 20, 2012

Monday, November 12, 2012

Chrome anomoly

event.srcElement.isContentEditable or event.target.isContentEditable was always returning false, even though it existed.


JQuery test for existance



if ($("#blah").length > 0) {


what confounds me  is the following failed



if ($("#blah ")[0].length > 0) {

just like JQuery will create an empty object with 0 length in case the object does not exist shouldn't it be referenced at [0]?

Chrome js debugger

does not loo through jquery's each

this was painful learning experience for me

Thursday, November 8, 2012

Color issues

I thought my code for alternate row colors was faulty - or a cascading issue.
In reality - my screen doesn't show the color

e.g. #f6f6f6 

IE9

tools-> compatibility view settings ->intranet by default is on

regardless of setting you can set the web page with the following meta

<meta http-equiv="X-UA-Compatible" content="IE=8" />

Monday, November 5, 2012

Basic linq syntax group by on datatable



            DataTable dt = new DataTable();
            dt.Columns.Add("a", typeof(string));
            dt.Columns.Add("b", typeof(string));
            dt.Columns.Add("c", typeof(string));
            DataRow dr =  dt.NewRow();
            dr[0] = "a - row1";
            dr[1] = DBNull.Value;
            dr[2] = "c -row1";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "a -row2";
            dr[1] = "b -row2";
            dr[2] = "c -row2";

            dt.Rows.Add(dr);

            var subjects = dt.AsEnumerable().GroupBy(row => new { a = row.Field<string>("a"),c=  row.Field<string>("c")}).Select(i => new { Subject = i.Key, Count = i.Count()}) ;
            foreach (var subject in subjects)
            {
                Response.Write(subject.Subject);
            }


results

{ a = a - row1, c = c -row1 }{ a = a -row2, c = c -row2 }
{ a = a - row1, b = , c = c -row1 }{ a = a -row2, b = b -row2, c = c -row2 }