Thursday, October 25, 2012

TryParseExact formats

what does this return?

DateTime.TryParseExact(stringArray[columnNum], "yyyy/MM/dd", dateTimeFormatterProvider, DateTimeStyles.None, out date)  when the value is 1999/02/23?


false

why? because its not a standard format?

the answer : use CultureInfo.InvariantCulture

Monday, October 22, 2012

Warnings in SSIS

apparently fail a package in run time, as opposed to , for e.g. , management studio which just shows a warning

Wednesday, October 17, 2012

DeletedRowInaccessibleException & linq

I was receiving this even though in the where clause I excluded deleted rows

i had to do this




//to avoid DeletedRowInaccessibleException errors AcceptChanges
            blah.AcceptChanges();

submitdisabledcontrols



submitdisabledcontrols="true" in the form tag will not help for when the server disables the control

Tuesday, October 16, 2012

simple c# function for stripping non-numeric


  public static string stripNonNumeric(string str)
            {
                Regex digitsOnly = new Regex(@"[^\d]");
                return digitsOnly.Replace(str, "");
            }

Great idea for builds

keep a separate workspace for builds and get the latest :this way you wont create a build from code not checked in.

Monday, October 15, 2012

Using Linq with datatables

you need a reference to datasetextensions.

the interesting thing was that was enough to bring up "where" and "order by"clauses but not group by - for that I needed a using system.linq

Sunday, October 14, 2012

Regional options and excel - 2 exceptions

windows doesn't change the format between dd-mmm-yy and dd-mmm-yyyy
also , windows doesn't handle yyyy-dd-mm properly
as you can see, it can't read 1999-23-01, therefore the format is general
1999-03-02, it can read and  does 2 boo-boos - it reads the day as the month and it formats it as dd-mm-yyyy


also interesting - dd-MMM-yy applied to 2-3-1999 produces 02-03-99 - no month string.

Sunday, October 7, 2012

Spreadsheetgear and dates

when you import dates from a s/sh , then if the format is set SG will get the value and format and allow you to acces the text. if however you are importing a csv - it will attempt to convert to the current culture

how to deal with a different format than the current culture:


CultureInfo TempCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
                    TempCulture.DateTimeFormat.ShortDatePattern = dateFormat;
                    //Thread.CurrentThread.CurrentCulture = TempCulture;
                    _wb = SpreadsheetGear.Factory.GetWorkbookSet(TempCulture).Workbooks.OpenFromStream(stream);
                    _data = _wb.GetDataSet(SpreadsheetGear.Data.GetDataFlags.FormattedText );
 

when converting to datatables make sure to get the formatted text:



DataSet dataSet = wb.GetDataSet(SpreadsheetGear.Data.GetDataFlags.FormattedText );

likewise:

range.CopyFromDataTable(dt, SpreadsheetGear.Data.SetDataFlags.AllText);