tag:blogger.com,1999:blog-56551802019-03-13T10:16:27.990+00:00DaddyCode Team BlogC# , ASP.NET, MVC, SQL, Sharepoint, JQuery and nowt else from a <a href="http://www.webdeveloperleeds.com">Web Developer in Leeds</a>James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.comBlogger171125tag:blogger.com,1999:blog-5655180.post-52480119781602716342018-04-09T11:20:00.001+01:002018-04-09T11:20:24.204+01:00Windows 10 Start Menu "Best Match" won't openIf you open your Win 10 start menu, search for an app and then click or press enter on the "Best Match" result, and it won't open, it's ANNOYING.
The solution is also annoying. There's a folder in your AppSettings that you're going to need to delete:
C:\Users\YOUR_USERNAME\AppData\Local\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy
However, you can't delete it while you're logged in. So James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-45154670608987940692017-05-01T17:52:00.000+01:002017-05-01T17:56:31.026+01:00Pick up Emails from IMAP
using (ImapClient client = new ImapClient("server.name", 993, "account.name", "account.passwd", AuthMethod.Login, true))
{
IEnumerable<uint> uids = client.Search(SearchCondition.SentSince(DateTime.Now.AddDays(-7)));
IEnumerable<mailmessage> messages = client.GetMessages(uids, FetchOptions.HeadersOnly);
}
James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com3tag:blogger.com,1999:blog-5655180.post-24850712748603069392017-01-20T10:40:00.003+00:002017-01-20T10:40:43.903+00:00Visual Studio 2015 crashes with "has stopped working" when searching Entire SolutionThe fix for me: Delete the hidden VS folder in the solution root.James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com2tag:blogger.com,1999:blog-5655180.post-38496897263145614312016-09-22T16:00:00.000+01:002016-09-22T16:02:48.582+01:00IIS 503 Service Unavailable - Classic ASPJust had the horrible 503 Service Unavailable issue when trying to view a Classic ASP site hosted on Windows 10 IIS. Turns out the Windows 10 Anniversary update broke it... but I digress....
In IIS I saw that the Classic ASP App Pool had stopped. But if restarted, it just stopped again when I hit the website.
Event Viewer said "The Module DLL C:\WINDOWS\system32\inetsrv\rewrite.dll failed to James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-47800779387194730952015-11-13T01:31:00.001+00:002015-11-13T01:31:21.452+00:00Use Technicolor modem as slave wireless access point1) Used "other" easy setup wizard to gain access to turn off DHCP on slave router
2) Set slave IP to be out of the DHCP range of the main router, but within the subnet.
3) Setup wifi SSID, password etc to match the main router, but use different wireless channel.
4) Put slave at opposite end of house, connected over powerline.
Bingo... Seamless wireless transition throughout the house and garden.James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-42732282075001192312015-09-11T13:00:00.002+01:002015-09-11T13:02:07.997+01:00Bluetooth Issues with Lenovo ThinkPad T410 - Error 1935Horrible recurring problems with this machine where the Bluetooth drivers get screwed up.
I tried to fix by downloading the latest ThinkPad Bluetooth with Enhanced Data Rate Software for Windows 7 and reinstalling, but it kept failing with the dreaded Error 1935. An error occurred during the installation of assembly 'Microsoft.VC80.ATL error.
The only thing that fixed this was by running the James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-90811659266110637782015-03-17T11:05:00.002+00:002015-08-28T15:20:14.076+01:00IIS 7 URL Rewrite - Ensure SSL/HTTPS and Ensure Fully Qualified Domain Name (FQDN) as HostnameI had the goal of ensuring all traffic on a web site was via SSL, and also using the canonical hostname, i.e. www.mysite.com rather than just mysite.com.
After installing URL Rewrite 2.0 on IIS, this was achieved by adding the following to the site's root web.config file.
James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-45799729615735470782015-02-16T11:37:00.001+00:002015-02-24T11:34:07.693+00:00Get Inserted ID from SQLOLEDB ADO Recordset.AddNew with SQL ServerMigrating a legacy ASP site to SQL Server, had a prob whereby lots of code that previously used RecordSet.AddNew() with RecordSet.Update(), and then immeditately retrieved the inserted ID from the RecordSet, suddenly failed to get the inserted ID.
The solution was to set the RecordSet CursorType to adOpenKeyset (constant value 1)James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-10369283452425261902015-02-10T10:42:00.001+00:002015-03-17T11:15:34.548+00:00Edit Web.Config from File Explorer in Windows 7 / 8 / 2012 - Read Only for AdministratorDon't you hate that UAC thing whereby you can't edit your site's web.config file directly from File Explorer? It lets you open it in notepad and then won't let you save. Even though you're an Administrator! ANNOYING!
It's because of the default Access Control List on the Inetpub folder. When you edit any file under that folder, Windows busts you down to User level permissions, even though your James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-46356108438025544162014-11-27T09:48:00.003+00:002014-11-27T09:48:51.821+00:00Lenovo ThinkPad T410 Fingerprint Reader stopped working after updateDid a long-put-off update on my Thinkpad with all its recommended Lenovo drivers from the ThinkVantage tool. All dandy, apart from the fingerprint reader stopped working. It used to have a little green light on to show it was ready, now it was off in sleep mode.
Simple solution: Go to Device Manager > Biometric Devices > TouchChip Fingerprint Coprocessor > Properties > Power Management and James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-36479816690726344682014-11-18T16:19:00.001+00:002014-11-18T16:19:12.138+00:00Remote Desktop connection failedCouldn't connect via RDC via an RD Gateway. Tried all sorts but in the end tried going into Device Manager, showing all hidden devices, and removed all the ISATAP virtual tunneling adapters that various Virtual Machines had added. It worked!James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-4570942606369936652014-10-22T10:26:00.002+01:002014-10-22T10:26:36.796+01:00Installation Ended Prematurely - MVC Hotfix MS14-059Just had a scary moment when a production MVC application went down due to MS Updates removing the MVC 3.0.0.0 dll and replacing it with MVC 3.0.0.1.
Although we located the MS Hotfix (MS14-059), the installer gave us a worrying "Installer Ended Prematurely" error.
The solution was simple - the server needed a reboot to allow it to install some pending updates before the Hotfix could be run.James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-21035076846026636322014-10-21T14:19:00.000+01:002014-10-21T14:33:32.640+01:00VBScript / Classic ASP value equivalency crib sheet
DBNULL VALUE
Equivalent to: NULL
ZERO VALUE
Equivalent to: FALSE
STRING NUMBER VALUE (e.g "0")
Equivalent to: NUMBER VALUE (but STRING ZERO is not FALSE!)
EMPTY VALUE / UNDEFINED VALUE / UNPROVIDED REQUEST VALUE
Equivalent to: FALSE (but not NULL!)
EMPTY STRING ("")
Not equivalent to FALSE, EMPTY, ZERO or NULL!
NOTE: If you compare NULL with anything, it just returns NULL, not TRUE/James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-69337993328884079532014-09-19T14:44:00.001+01:002014-09-19T14:44:08.593+01:00A simple script for scheduled Access DB backupsHere's a simple wee backup script to save as a VBS file (e.g. backup.vbs) and then run from Windows Task Scheduler.
Saves a copy with a datestamp in the filename e.g. Data_2014-09-07.mdb
Dim oldfilePath
Dim newfilePath
oldfilePath = "C:\LivePath\Data.mdb"
newfilePath = "D:\Data_Backups\Data_"
newfilePath = newfilePath & datepart("yyyy", date()) & "-"
newfilePath = newfilePath & Right("0" & James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-29940979688255913242014-08-25T11:47:00.004+01:002014-08-25T11:51:07.046+01:00Adding a Clear Filter / Clear Search Button to DataTablesI wanted a generic way to add a "clear filter" button to the text filter on all the DataTables on a site.
One way would be to change the input type of the filter to "search" - then HTML5 browsers will automatically show a clear widget. However, you'd have to press return after clicking it, so I wanted a one-click solution.
Here's what I came up with. It works with DataTables 1.9.
// Setup James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com4tag:blogger.com,1999:blog-5655180.post-62792258620918896732014-05-16T12:19:00.000+01:002014-05-16T12:19:08.940+01:00A ValueInjecter Injection that ignores null valuesWant to use ValueInjecter but don't want to copy null values into your model?
public class NoNullsInjection : ConventionInjection
{
protected override bool Match(ConventionInfo c)
{
return c.SourceProp.Name == c.TargetProp.Name
&& c.SourceProp.Value != null;
}
}
Usage:
target.InjectFrom(new NoNullsInjection(), source);
James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-82439683986472037752014-04-15T17:42:00.000+01:002014-09-19T14:46:02.303+01:00Access MDB activity causes Visual Studio 2012 "File Modified Outside Environment" warningI've found a way to stop this when it starts. Close VS2012 and delete your Visual Studio solution's (hidden) SUO file, which you will find with the SLN file.James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-37420743754034062982014-02-10T17:24:00.002+00:002014-02-10T17:24:54.984+00:00Classic ASP FPDF creates TMP files in folderWeird little problem just now - a classic ASP (vbscript) page used FPDF to generate PDF files. All working fine but weirdly, the script seemed to be generating TMP files in its directory - one for each PDF generated.Took a while to figure out, but turned out that the IIS user account had WRITE permission on the folder but not MODIFY. Once MODIFY was added, the TMP file problem went away. Small James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-50235007802807287302014-02-06T00:38:00.002+00:002014-02-06T01:53:43.454+00:00Lottie Dexter (Year of Code) and Jeremy Paxman on BBC Newsnight 5 Feb 2014Okay, just finished watching this debacle and want to reel off some thoughts. Venty venty.
I guess it must be true for any skilled worker that when journalists cover your area of expertise, your hackles rise and you begin to wonder what basic stuff is being misunderstood and misrepresented by those journalists in all the other articles you've ever read on other subjects. Fair enough, journalistsJames McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com7tag:blogger.com,1999:blog-5655180.post-12956248690225179212014-01-27T20:30:00.000+00:002014-01-27T20:32:25.974+00:00PostCode Anywhere, JSONP and IE7 Cross Domain problemsFirst off, let me say that I like Postcode Anywhere (PCA), they're a great service.
Today I had to fix a bug with a site using PCA's Bank Account Validation. It was working great generally, but failing for IE7.
IE7! The bane of my life! It doesn't use CORS, doesn't even use IE8's crappy XDomainRequest object. It just plain can't make an AJAX call to an endpoint on a different domain.
This was James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-49947362950005598412014-01-27T16:50:00.002+00:002014-02-05T13:44:51.648+00:00JQuery Conditional Validation (Yes, the official documentation sucks)Venting! jQuery Validation is a great plugin but its documentation is crap! So much cool stuff is hidden away for want of decent docs. If enough of you agree with me, I might have to write some! Watch this space.
Anyway, I just wanted to implement some conditional validation
i.e. MAKE INPUT 'A' REQUIRED ONLY IF INPUT 'B' HAS A VALUE
And so, given two inputs with IDs InputA and InputB, the James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com1tag:blogger.com,1999:blog-5655180.post-21084500172656332082014-01-08T18:32:00.002+00:002014-01-08T18:32:45.956+00:00ADODB.Command error '800a0cc1' Item cannot be found in the collection corresponding to the requested name or ordinal.If you get this error when you're doing classic ASP with an MS Access backend:
ADODB.Command error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
And it doesn't make sense.... check that you haven't got that table open in Access. Doh! Stupid error message!James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0tag:blogger.com,1999:blog-5655180.post-26515723447870125652013-12-19T15:33:00.001+00:002013-12-19T15:35:38.373+00:00Ordinal Suffix in C# / .NET e.g. the postfix part of 1st, 2nd, 3rd, 4thDEFINITIVE ANSWER TIME :)
Here's a natty extension method to get the Ordinal Suffix of a number.
public static string GetOrdinalSuffix(this int number, bool includeNumberInResult = false)
{
string suffix = "th";
if (Math.Floor(number / 10f) % 10 != 1)
{
switch (number % 10)
{
case 1:
suffix = "st";
break;
case 2:
suffix = "nd";
break;
case 3:
suffix = "rd";
James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com1tag:blogger.com,1999:blog-5655180.post-8745963860784364092013-12-16T21:56:00.000+00:002013-12-16T21:57:04.215+00:00Handling File Uploads from Dropzone.js with ASP.NET MVCI had a need recently on an MVC project to allow the upload of image files. Having a look around to check if I was still using the best tools for the job, I came across DropzoneJS , which is excellent.
However, the documentation is a little terse and there are no MVC integration guides yet, so let me present a sample Controller Action for anyone who wants to simply see how to use it.
public James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com3tag:blogger.com,1999:blog-5655180.post-22470572837999366542013-09-12T10:40:00.001+01:002013-09-12T10:40:19.612+01:00Modelling a Stored Procedure in EF: The selected stored procedure returns no columnsTrying to map a SQL Stored Procedure in Entity Framework in Visual Studio, I clicked "Update my Model from Database" on the EDMX view, and added the Stored Procedure. However, unlike other ones I had imported, when I looked in Model Browser, no Complex Type was created in the model to represent the result rows of the Stored Proc.
When I clicked on the Function Import for the sproc, The Return James McCormackhttp://www.blogger.com/profile/02802202320696705884noreply@blogger.com0