Wednesday, August 31, 2011

When integrating with Chase Payemtech E-Xact Pay-Pages, I could not get the HMAC-MD5 hash to generate properly and match what their Hash Generator was producing. After reading up on HMAC (http://en.wikipedia.org/wiki/HMAC)

I ran some of their samples and found that what was being generated from the HMAC-MD5 was the same result as HMAC SHA1 and NOT what the wiki said should be produced for HMAC-MD5.

Solution? change the Pay-Page configuration to use SHA1 and use SHA1 to generate all the request and response validation hashes.

x_fp_hash

Tuesday, August 30, 2011

taskmanager windows mobile
force close an application on a windows mobile device
Settings > System > Memory > Running Programs

Select app and click
Or
Click

Wednesday, June 08, 2011

Collection of IF EXISTS statements for SQL

IF EXISTS (SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Aparc_SpaceSensorHistory' AND COLUMN_NAME = 'RecordedOn')

IF EXISTS (SELECT * FROM sys.foreign_keys
WHERE object_id = OBJECT_ID(N'[dbo].[FK_Aparc_ParkingSpace_Aparc_ParkingSpace]') AND parent_object_id = OBJECT_ID(N'[dbo].[Aparc_ParkingSpace]'))

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Aparc_ParkingSpace]') AND type in (N'U'))

SELECT * FROM sys.constraints

ALTER TABLE dbo.Aparc_SpaceSensorHistory
DROP CONSTRAINT DF_Aparc_SpaceSensorHistory_RecordedOn
END

ALTER TABLE dbo.Aparc_SpaceSensorHistory ADD
RecordDate datetime NOT NULL CONSTRAINT DF_Aparc_SpaceSensorHistory_RecordDate DEFAULT getdate()

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CorrectSpaceNumber]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[CorrectSpaceNumber]

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Aparc_ParkingPlateHistory]') AND name = N'IX_Aparc_ParkingPlateHistory')
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Aparc_ParkingPlateHistory]') AND name = N'PK__Aparc_ParkingSpace')

if not exists (select name from sys.objects where type_desc = 'DEFAULT_CONSTRAINT' and name = 'DF_AID_AGENCY_STAFF_CSR')

IF EXISTS(SELECT * FROM SYS.OBJECTS WHERE type_desc = 'DEFAULT_CONSTRAINT' AND parent_object_id = OBJECT_ID(N'[dbo].[Aparc_ParkingPlate]' and name = 'DF_AID_AGENCY_STAFF_CSR'))

Tuesday, April 19, 2011

System.Data.Odbc.OdbcException: ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Failure getting record lock on a record from table PUB.#####.

Solution: Add the no-lock statement to each select statement.

SELECT * FROM PUB.##### WITH(NOLOCK)

Tuesday, April 12, 2011

I was getting a System.ObjectDisposedException when trying to serialize/remote a LINQ result set via a webservice. The actual data result was fine. The problem lay with the parent and child relationships generated by LINQ. Looping through each result and setting all the relationship objects to null stopped the exception, but that was not a solution (merely identified the source of the issue). The solution (provided to me by co-worker: Robert Blasutig), is to prevent LINQ from trying to load parent and child relationships automatically.

This is done by setting the DeferredLoadingEnabled property of the context to false.

To then have LINQ load parent/child objects later, you must specify which relationships to load with the following:

using (ClientDBDataContext clientCtx = new ClientDBDataContext(clientDbConnStr))
{
clientCtx.DeferredLoadingEnabled = false;

DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith(dtAlias => dtAlias.ParentChildTableName);
clientCtx.LoadOptions = loadOptions;

...query...
}

FULL EXCEPTION:

System.InvalidOperationException: There was an error generating the XML document. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'DataContext accessed after Dispose.'.
at System.Data.Linq.DataContext.GetTable(Type type)
at System.Data.Linq.CommonDataServices.GetDataMemberQuery(MetaDataMember member, Expression[] keyValues)
at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.ExecuteKeyQuery(Object[] keyValues)
at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.Execute(Object instance)
at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.DeferredSource.GetEnumerator()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at System.Data.Linq.EntityRef`1.get_Entity()
at AparcSystems.AparcDataAccess.Aparc_PdmTariff.get_Aparc_EnfArea()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write25_Aparc_PdmTariff(String n, String ns, Aparc_PdmTariff o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write57_ArrayOfAparc_PdmTariff(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.ListOfAparc_PdmTariffSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()

Monday, April 11, 2011

"DoInsertLogbookRecord"
"DoInsertTransLogRecord"

"Transaction context in use by another session"

Trigger code updates a table in a database in local instance. Does not require (ie CANNOT HAVE) reference to [server\instance] name in target.

Monday, January 17, 2011

Thursday, December 02, 2010

doctrine "Missing class name"
Doctrine::generateModelsFromDb()

Doctrine fails with generic exception "Missing Class Name"

the model generation fails due to cross databases foreign key constraints.


PHP MAMP MySQL NaviCat

Monday, November 15, 2010

How to check open connections to a Progress database:

proenv>e:
nav to DB file dir

proenv>cd progress\databases\customerDB

proenv>promon databaseName

use Promon instructions to view various statuses of the db and users

1. User Control
2. Locking and Waiting Statistics
3. Block Access
4. Record Locking Table
5. Activity
6. Shared Resources
7. Database Status
8. Shut Down Database

ETC...

Saturday, November 13, 2010

Progress Reports will not show.

All connections to progress database are used ("No Resources Available"). Must clear a connection and terminate process.

Wednesday, November 10, 2010

Error:
Warning: include_once(Zend/Form/Element/password.php): failed to open stream:

Solution:


$password = new Zend_Form_Element_Password('password');

Zend_Form_Element_Password is CASE SensiTive

Tuesday, August 24, 2010

iPhone - Verify account info: security code invalid

Set the credit card to "None" and save.
You can re-add the credit card number later.

Monday, August 23, 2010

How to manually add a Progress OpenEdge ODBC Driver


ALERT: This requires registry edits, so take your normal precautions.

Launch:
regedit.exe

Navigate to:
(Windows)
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI

(64bit Windows 7)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI

Add/Create the following key:

Progress OpenEdge [XX.XN] Driver

Where [XX.XN] is your available version of the Progress bin. (e.g. 10.2C)

Open the Progress OpenEdge XX.XN Driver key and add the following strings (REG_SZ):
APILevel = "1"
ConnectFunctions = "YYN"
CPTimeout = "60"
DriverODBCVer = "3.50"
FileUsage = "0"
SQLLevel = "0"
UsageCount = "1"
Setup =  "[PATH]\pgoe1023.dll"
Driver = "[PATH]\pgoe1023.dll"

Where [PATH] is the location of the "pgoe1023.dll" library (e.g. "C:\Progress\V102A\bin").

HINT: You may place the bin file(s+) anywhere on the local system.

Next, Navigate to:
(Windows)
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers

(64bit Windows 7)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers

Add the following string (REG_SZ):
Progress OpenEdge [XX.XN] Driver = "Installed"

Where [XX.XN] is your available version of the Progress bin. (e.g. 10.2C)

You will now see the Progress OE ODBC driver available in the ODBC Manager (SysWoW64 version for Windows 7).

connection string sample:
<add name="ProgressDb" connectionString="DRIVER=Progress OpenEdge 10.2A driver;HOST=localhost;PORT=9999;DB=databaseName;UID=userId;PWD=password;" />
How to manually add a Progress OpenEdge ODBC Driver

Launch regedit.exe
Navigate to:
(Windows)
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI

(64bit Windows 7)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI

Add/Create the following key:

Progress OpenEdge [XX.XN] Driver

Where [XX.XN] is your available version of the Progress bin. (e.g. 10.2C)

Open the Progress OpenEdge XX.XN Driver key and add the following strings (REG_SZ):
APILevel = "1"
ConnectFunctions = "YYN"
CPTimeout = "60"
DriverODBCVer = "3.50"
FileUsage = "0"
SQLLevel = "0"
UsageCount = "1"
Setup =  "[PATH]\pgoe1023.dll"
Driver = "[PATH]\pgoe1023.dll"

Where [PATH] is the location of the "pgoe1023.dll" library (e.g. "C:\Progress\V102A\bin"). You may place this file anywhere on the local system.

Next, Navigate to:
(Windows)
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers

(64bit Windows 7)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers

Add the following string (REG_SZ):
Progress OpenEdge [XX.XN] Driver = "Installed"

Where [XX.XN] is your available version of the Progress bin. (e.g. 10.2C)

You will now see the Progress OE ODBC driver available in the ODBC Manager (SysWoW64 version for Windows 7).

Wednesday, August 18, 2010

ODBC Driver Issue:  Progress OpenEdge - error code 193

You are trying to create a 64bit ODBC connection using a 32bit driver and the 32bit driver does not appear in the 32bit ODBC connection manager (SysWOW64)

You need to add the following keys:


[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers]
"Progress OpenEdge 10.2A driver"="Installed"


[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Progress OpenEdge 10.2A Driver]
"Driver"="[DLC]\\bin\\pgoe1023.dll"
"Setup"="[DLC]\\bin\\pgoe1023.dll"
"DriverODBCVer"="3.50"
"APILevel"="1"
"ConnectFunctions"="YYN"
"CPTimeout"="60"
"FileUsage"="0"
"SQLLevel"="0"
"UsageCount"="1"

[DLC] should refer to the 10.2A installation directory

{From ProgressTalk Kbase Solution P141118} ERROR System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Be sure the ODBC connection is defined as a System DSN and was created using the C:\Windows\SysWow64\ODBCad32.exe Also be sure that the AppPool running a webservice using the DSN is enabled for 32 bit applications.

Thursday, August 12, 2010

Set multiple sites running SSL over port 443 in IIS


c:\windows\system32\cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set /w3svc/52796006/SecureBindings ":443:www.domain.com"

Wednesday, August 04, 2010

Progress SQL ODBC errors:

i) System.Data.Odbc.OdbcException: ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Invalid number string (7498)

SOLUTION: Lookup Type/Value Not Found - check values bound to lists/types

ii) [PROGRESS]Lock table is full. (7870)
sol: # Lock Table Entries is too small. Increase in ODBC connection properties.

iii) [System.Data.Odbc.OdbcException] = {"ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Character string is too long (8184)"}

SOLUTION: Text in a Formatted field (Date or Time or Currency...) contains invalid or extra characters (" ", leading space).

iv) [ODBC Progress OpenEdge Wire Protocol driver]Optional feature not implemented.
[OPENEDGE]Broker rejects connection

SOLUTION: PEO database is not setup for SQL (4GL only) OR Database needed a restart.

Wednesday, July 28, 2010

SQL Server 2005 - Loop through/split a delimited string
Here is a further cleaned up, generalized, and working version of a T-SQL script to take in comma delimited list and parse it into elements and operate on the individual values:


GO
DECLARE @commaList AS VARCHAR(MAX)
SET @commaList = '1,2,3,4'

DECLARE @pos as INT
IF substring(@commaList, LEN(@commaList),1) <> ','
        SET @commaList = @commaList + ','

print substring(@commaList, LEN(@commaList),1)
SET @pos=0
DECLARE @listItem as int

WHILE charindex(',',@commaList)>0
    BEGIN
        SET @listItem = cast(substring(@commaList,0, charindex(',',@commaList)) as int)
        /***********PERFORM ACTION***********/
        PRINT @listItem
        /*************END ACTION*************/
        SET @commaList = substring(@commaList, charindex(',',@commaList)+1, LEN(@commaList) - @pos) --remove the first item from the list
    END

GO

The original script came from here, but was too specific to the original writer's needs and did not perform any action on the last value...
The original writer also mentions, that he (and I) does the cast to int because he requires an INT. If you do not, do not do the cast.

"SQL Server 2005 - Loop through/split a delimited string"
http://www.vbforums.com/showthread.php?t=507592

Tuesday, June 29, 2010

Windows 7 Blackscreen of Death BSOD - Completely black desktop with mouse activity.

Just got a windows 7 notebook machine back up and running after suffering the BlackScreenOfDeath Issue.

Initially I suspected that the screen settings had shifted the desktop off to an external monitor which was not currently attached. But when no context menu came up from a right click of the desktop, I realized there was no desktop running. This led me to believe that explorer.exe had not started. So with a ctrl+alt+del I got to the task manager (good sign) and could see that indeed there was no explorer.exe process running.

The next step was to try and fire it up manually using the "New Task" button on the Task Manager. This only returned an error message stating that no explorer.exe could be found. I did a little Google-ing to confirm that explorer  was still explorer in Windows 7 (which it is). Along with that Google search I found out that I was experiencing the BlackScreenOfDeath issue and that the security company PrevX had a solution (PrevX Article).

I later read that the PrevX solution was not the fix-all. It did address the issue of a possible missing registry key which points to the location of explorer.exe for the system to launch the desktop process when a user logs on. After confirming the registry key was intact, off to confirming the location of the exe.

The explorer.exe file should be located in the Windows directory, but it was not. Which explains why the desktop failed to launch leaving the user with the BSOD. I did a search of the user's hard drive and found several versions of the exe in question in subdirectories located in the Windows\winsxs directory. Curiously, I launched one of the executables located under an "AMD64..." directory (even though this was an INTEL) and the desktop loaded. The explorer.exe's under the "WOW64..." and "X86..." directories failed to launch with an error.

In the end, I copied the explorer.exe (the one that worked) from the Windows\winsxs\AMD64... directory into the Windows directory and restarted the machine.

Whaa Lahh, the machine is golden. Hope this helps.

Wednesday, June 23, 2010

From TIM


Serialize (convert an object instance to an XML document):
// Assuming obj is an instance of an object
XmlSerializer ser =
new
XmlSerializer(obj.GetType());
System.Text.StringBuilder sb = new
System.Text.StringBuilder();
System.IO.StringWriter writer = new
System.IO.StringWriter(sb);
ser.Serialize(writer, obj);
XmlDocument doc = new
XmlDocument();
doc.LoadXml(sb.ToString());

Deserialize (convert an XML document into an object instance):
//Assuming doc is an XML document containing a serialized object and objType is a System.Type set to the type of the object.
XmlNodeReader reader =
new
XmlNodeReader(doc.DocumentElement);
XmlSerializer ser = new
XmlSerializer(objType);
object
obj = ser.Deserialize(reader);// Then you just need to cast obj into whatever type it is eg:
MyClass myObj = (MyClass)obj;



Thanks Tim