Thursday, May 9, 2013

Linq to select all rows with data in datable

_data.Tables[tempStr].Rows.Cast<DataRow>().Where(row => !row.ItemArray.All(field => field is System.DBNull || string.Compare((field as string).Trim(), string.Empty) == 0)).CopyToDataTable();

Monday, May 6, 2013

format config files in notepad++ nicely



alt-L -> X

removing a row in spreadsheetgear from a range

You can't do this   range( "1:1").delete - you will get an error that s/sh gear can only delete a full row

You can't refer to the underlying location values

you have to refer to the row of the range as if the range is a full spreadsheet

this is what I did
 public static IRange RemoveHeader(IRange range)
        {
            try
            {
                string startingCol ="a";
                string endingCol = GetExcelColumnName(range.ColumnCount);
                int startRow =  2;
                int endRow = range.RowCount;
                string newrange = string.Format("{0}{1}:{2}{3}", startingCol, startRow, endingCol, endRow);
                if (!range.Union(range.Range[newrange]).Equals(range))
                {
                    throw new EExcelUtilsRangeOutOfBoundsOfData();
                }
                return range[newrange];
            }
            catch
            {
                throw new EExcelUtilsRangeOutOfBoundsOfData();
            }

        }

Guid like strings in SQL

we were having an issue that there was a table that had all string values, guids and non guids, and a join on a guid table was failing so we did this


      select * into #blah
  from
  blah WITH (NOLOCK)
       where string_val LIKE REPLACE('00000000-0000-0000-0000-000000000000', '0', '[0-9a-fA-F]')

Wednesday, May 1, 2013

Defaults with WCF

if you set up a WCF service the default Binding type will be basicHttpBinding

when you create a reference the name of the binding will be basicHttpBinding_theinterface

it makes no difference if the name is different on the client , as long as the type is the same

Spreadsheetgear Issue with Macros

S/shgear lists macros under namedranges

this makes no sense to me

I had to do this to weed them out:



SpreadsheetGear.IRange tempName = name.RefersToRange;
                    //tempName.Name!= null avoids adding macros
                    //wish s/sh gear had a better way of identifying name type
                    if (tempName != null && tempName.Name!= null)
                    {