Thursday, July 23, 2015
SqlException error numbers for deadlock, connection and command timeouts
When accessing SQL Server via SqlClient (could be ADO.net or Entity Framework), any error is wrapped in an instance of SqlException and the Number property will be set to provide an indication of the specific error condition. In the event of a connection timeout, the Number property will be set to either 2 or 53. A command timeout will set the Number property to -2. And a deadlock will return 1205 in the Number property.
Thursday, July 16, 2015
Splitting and combining strings with TSQL
Previously the rules were written in a very straight-forward manner. Usually something similar to:
UPDATE transactions
SET
reason = reason + 'A'
, status=6 -- exception
WHERE {some rule}
It's probably obvious where the blocking became a problem.
Our alternate approach was to collect the a list of invalid transactions and the rule that was violated into a table and mark all of the affected transactions with a single UPDATE.
CREATE TABLE #badRows (id BIGINT, rule char(1));
INSERT INTO #badRows (id, rule)
SELECT id, 'A'
FROM transactions
WHERE {some rule}
The next challenge was pivoting and rule-violation codes into a single string so that the reason field of the transaction could be updated, with the additional constraint that any existing rule-violation code had to be maintained. We came up with the following:
;WITH both AS (
-- combine existing violations with any new ones
SELECT t.id, t.reason
FROM transactions t
INNER JOIN #badRows br ON br.id = t.id
UNION ALL
SELECT id, rule FROM #badRows
)
, ix AS
(
-- split any strings into single characters
SELECT id, SUBSTRING(reason,Number,1) AS code
FROM both
INNER JOIN master.dbo.spt_values ON Number BETWEEN 1 AND LEN(reason) AND type='P'
)
, crushedReasonCodes AS (
-- combine multiple rows into a single string
SELECT DISTINCT id, (
SELECT DISTINCT code AS [text()]
FROM ix
WHERE ix.id = o.id
FOR XML PATH ('')) as reason
FROM ix AS o
)
UPDATE transactions
SET reason = crc.reason
, status = 6
FROM transactions t
INNER JOIN crushedReasonCodes crc ON crc.id = t.id
Friday, July 3, 2015
Installing Windows 10 Build 10162 on a Dell Venue 8 Pro
- Dell Venue 8 Pro 5830 System BIOS (vA10)
- Intel Trusted Execution Engine Interface Driver (v1.0.0.1054)
- Intel Atom Z3000 Series Driver (v603.9600.2067.27988)
- Dell Wireless 1538 WiFi+Bluetooth Driver (v3,7.2.59)
Wednesday, March 4, 2015
Visual Studio 2013 APPCRASH KERNELBASE.DLL
Faulting application name: devenv.exe,
version: 12.0.31101.0,
time stamp: 0x54548724
Faulting module name: KERNELBASE.dll,
version: 6.3.9600.17415,
time stamp: 0x54504ade
Exception code: 0xe06d7363
Fault offset: 0x00014598
Faulting process id: 0x940
Faulting application start time: 0x01d056d558e8e214
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
It started right after I had applied a couple of Windows updates so I started trying to resolve the problem by rolling those back. No change.
I tried resetting the Visual Studio users settings. Nope.
Integrity scan of the disk. No problems found.
Turned to the Internet and found this answer in the Microsoft forums. It seems that my User Profile was corrupted. I created a new account on the machine, killed the previous one. Done.
Thursday, December 4, 2014
Reversing a file with Powershell
As it happens, get-content returns it's results as an array.
And you can reverse an array using the static Reverse() method
And you can write an array using out-file.
A quick example:
$c = (get-content deadlock.log)
[array]::Reverse($c)
$c | out-file "rev-deadlock.log"
Saturday, October 8, 2011
Metro style apps–loading an image from content
I’m writing a Win8 Metro style app and I wanted to expose an image from one of my view models. The image comes from a file that I have included in the project as content. After wandering through the samples, I was finally able to piece together this solution:
The XAML binds to the property using the Source attribute:
Some things to note. The image’s Build Action is set to Content and the path delimiters in the call to ResourceLoader.GetFile() use forward slashes (“/”). Using a backslash results the exception: NamedResource Not Found (HRESULT 0x80073B17).
Wednesday, September 28, 2011
Windows Phone 7 syncing to online Exchange results in Error 85010014
I upgraded my phone to the Mango update yesterday. Everything went fine except or so I thought. This morning I noticed that my phone hadn’t synced to the company’s Exchange account (Microsoft BPOS) for over 10 hours. When I forced a sync, it resulted in the following error message:
Not Updated
There’s a problem with red001.mail.microsoftonline.com. Try again later.
Last tried xx seconds ago
Error code: 8510014
I screwed around with the configuration for more time than I should have. I tried reentering the server. I tried entering the password again. I even removed the account from the phone and recreated it.
I even went to the Mobile Devices section on OWA and removed the device and then removed the account AGAIN.
Nothing worked.
This evening I stumbled onto something that did work.
I recreated the account on the phone (for the fourth or fifth time) and received the error again. On a whim, I unchecked all the content types under the Content to Sync section (Email, Contacts, Calendar and Tasks). I then issued a sync and it worked! I then added Email and re-synced. That worked! I continued to add the other three items, one at a time and followed by a re-sync.
Now everything is good again.