Friday, 3 October 2014

A duplicate value cannot be inserted into a unique index - SQL Error


You will typically receive this error when you are attempting to insert a row into a table. A column within your table will be a unique indexed column (Probably a Primary Key), and your new row has a value for this column which already exists within the database, making it a duplicate.

If the problem is your primary key, it's probably set to auto-increment and you have recently dropped some tables or refreshed your database for example. The problem therefore lies with your databases Seed Value. With the auto-increment properly of the primary key, the Seed Value will determine the next ID for your primary key. Chances are this has probably been reset with your recently database refresh. You can solve this issue with the following line of code...

ALTER TABLE tablename ALTER COLUMN columnname IDENTITY (newseedvalue, 1)

If your primary key values end at 150 for example, then you should replace 'newseedvalue' with 151. This will then be the new seed value for the next primary key.

Example (Start PK Identity at 1 for the tblNames table):
ALTER TABLE tblNames ALTER COLUMN ID IDENTITY (1, 1)

Thursday, 25 September 2014

.NET Windows Forms - Getting Docking to Work Properly!


Docking layout depends on the order of sibling controls. A docked controls only take the layout of previousdocked siblings into account. Hence the control with Dock=Fill should be last in the sibling order, if you want it to take the other docked controls into account, and not just be overlapped by them.
This can be confusing because the sibling-order is not necessarily the same as the visual order, and the sibling order is not always apparent from the design view.
The Document outline window (View -> Other Windows -> Document outline) gives a useful tree-view over the control hierarchy and order, and allows you to change the sibling order of controls.
You can also change sibling order directly in the designer by context menu -> Bring to front / Send to back, which moves the control to be first or last of the siblings. These menu labels may be somewhat confusing since the actual effect depends on the layout model.
With fixed positioned controls, the 2D position is independent of the sibling order, but when controls are overlapping, the control earliest in the order will be "on top", hiding part of siblings later in the order. In this context Bring to front / Send to back makes sense.
Inside flow- or table-layout panels, the creation order determines the visual order of the controls. There is no overlapping controls. So bring to front/send to back really means make first or last in the order of controls.
With docked layout, the bring to front / send to back may be even more confusing since it determines in which order the docking is calculated, so "bring to front" on a fill-docked control will place the control in themiddle of the parent, taking all edge-docked controls into account.

Sunday, 7 September 2014

AddThis vs ShareThis vs Sociable (Social Media Plug-In Comparisons)


Very good article on the comparison of different social media plugins for website integration. Check it out!

http://www.hyperlinksmedia.com/learning-center/helpful-web-tools/addthis-vs-sharethis/

Friday, 23 May 2014

How to Clear Error 5200 / P08 & Reset Printer Hardware (Canon Pixma MG2100 MX and S series printers)


Perform these steps to reset most Canon Printers. It works with MG / MX / M / PIXMA series and many more!

Step 1) Unplug the printer from Power and wait 5 sec then Plug it back in.
Step 2) Press "Stop/Reset" button for 2 sec and hold it.
Step 3) Now Press and hold the "Power" button also with "Stop/Reset" for 5 sec.
Step 4) Release only "Stop/Reset" and wait for 2 sec (still holding "Power" button)
Step 5) Now press and release "Stop/Reset" 5 times.
Step 6) After 5 sec release "Power" button also (No LCD only power light seen).
Step 7) Wait for a minute (after the printer resetting).
Step 8) Now power off the printer by pressing "Power" button.
Step 9) After 30 Seconds press "Power" button again. Now you're ready to print !!!

All printer errors should be cleared!

Wednesday, 6 March 2013

Evasi0n - iOS 6.1.2 Untethered Jailbreak [v1.5 Released!]


Evasi0n is an untethered jailbreak for iOS 6.1.2! Download and view below! View and Download

Sunday, 10 February 2013

CSS - Web Safe Font Stacks


Found a really good site that provides web-safe CSS font stacks for the font-family property. They provide serif, sans-serif (no tails!) and monospace font stacks.

Enjoy!

Link Here: CSS Friendly Font Stacks

Wednesday, 30 January 2013

C#: Send a simple E-Mail via. Google Gmail SMTP Server



Here's a code snippet which allows you to send an E-Mail using Gmails SMTP server...



Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Mail;
  6. using System.Text;
  7.  
  8. /// <summary>
  9. /// Simple Emailer class for sending a simple email.
  10. /// </summary>
  11. public class Emailer
  12. {
  13.     /// <summary>
  14.     /// Takes a users email and item name and generates an email
  15.     /// </summary>
  16.     /// <param name="recipient">Recipients e-mail address</param>
  17.     public static void SendMail(string recipient)
  18.     {
  19.         try
  20.         {
  21.             // Setup mail message
  22.             MailMessage msg = new MailMessage();
  23.             msg.Subject = "Email Subject";
  24.             msg.Body = "Email Body";
  25.             msg.From = new MailAddress("FROM Email Address");
  26.             msg.To.Add(recipient);
  27.             msg.IsBodyHtml = false; // Can be true or false
  28.  
  29.             // Setup SMTP client and send message
  30.             using (SmtpClient smtpClient = new SmtpClient())
  31.             {
  32.                 smtpClient.Host = "smtp.gmail.com";
  33.                 smtpClient.EnableSsl = true;
  34.                 smtpClient.Port = 587; // Gmail uses port 587
  35.                 smtpClient.UseDefaultCredentials = false; // Must be set BEFORE Credentials below...
  36.                 smtpClient.Credentials = new NetworkCredential("Gmail username", "Gmail Password");
  37.                 smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
  38.                 smtpClient.Send(msg);
  39.             }
  40.         }
  41.         catch (SmtpFailedRecipientsException sfrEx)
  42.         {
  43.             // TODO: Handle exception
  44.             // When email could not be delivered to all receipients.
  45.             throw sfrEx;
  46.         }
  47.         catch (SmtpException sEx)
  48.         {
  49.             // TODO: Handle exception
  50.             // When SMTP Client cannot complete Send operation.
  51.             throw sEx;
  52.         }
  53.         catch (Exception ex)
  54.         {
  55.             // TODO: Handle exception
  56.             // Any exception that may occur during the send process.
  57.             throw ex;
  58.         }
  59.     }
  60. }
End of Code Snippet

Thursday, 22 November 2012

Facebook Developer: Debugger


Not sure how many of you know about this, but check out the Facebook Debugger!

You can enter an Input URL, Access Token, or Open Graph Action ID!

View Here: http://developers.facebook.com/tools/debug

Error when saving a table in SQL Server: "Saving changes is not permitted"


Error Message
Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

Why?
This problem occurs when the Prevent saving changes that require the table re-creation option is enabled, and you make one or more of the following changes to the table:
  • You change the Allow Nulls setting for a column.
  • You reorder columns in the table.
  • You change the column data type.
  • You add a new column.
When you change a table so that you alter the metadata structure of the table, and then you save the table, the table must be re-created based on these changes. This may result in the loss of metadata and in a direct loss of data during the re-creation of the table.

Fixing the Problem

OPTION 1 - Using the ALTER SQL keyword to change the table definition.

Code Snippet
  1. ALTER TABLE NameOfTable ALTER COLUMN ColumnToAlter INT NOT NULL
End of Code Snippet

Option 2 - Turning off the "Prevent saving changes that require table re-creation" option. NOT RECOMMENDED!. This may cause data loss due to changes with the meta structure of the table. A good example of potential data loss is if you enable Change Tracking.

If you only have the table structure set up and/or data loss isn't an issue (Test Data for example), then here are the following steps to turn off this data protection feature.

1. Open SQL Server Management Studio (SSMS).
2. On the Tools menu, click Options.
3. In the navigation pane of the Options window, click Designers.
4. Select or clear the Prevent saving changes that require the table re-creation check box, and then click OK.




Joining MP4 Files together without Re-Encoding (Windows and MAC)


OPTION 1 - MP4Join (Cross Platform) [RECOMMENDED!]

VERY simple cross platform solution to join MP4 files. Just add them to the lit, re-order them, and it will simply copy the next video on to the previous at the end of the last frame. It will output the final MP4 without loss of quality or re-encoding.

Download Here: http://www.mp4joiner.org/en


OPTION 2 - Quicktime (7 or X at time of writing). Windows users must use Quicktime PRO ONLY.

1. Open the two H264 videos in Quicktime 7. Let's suppose they are named video1.mp4 and video2.mp4.

2. Working on video1.mp4, Select All, then Copy.

3. Switch to video2.mp4, make sure the "cursor" is at the beginning of the video, then Paste. This inserts the content of video1.mp4 at the front of video2.mp4.

4. This step is probably optional. "Save As" the modified video2.mp4. You will be able to save in .mov format only. I saved as a self-contained movie, but I suppose a reference movie would work too. I used the filename "video.mov".

5. Select "Export" in the file menu to export video.mov to the joined H264 file. The "Export" to select is "Movie to MPEG-4". The preset is not important, I chose "LAN/Intranet". The preset is not important because we override it in the next step.

6. Click on "Options" to reach the settings dialog. In the Video pane, "Video Format" is selected to be "H.264". Click on the menu, select "Pass Through". As expected, all the other options will get disabled.

7. Click OK, then Save, and watch your joined file be saved at the speed of your hard disk.


OPTION 3 - MAC Users Only!

SimpleMovieX, a shareware video editor which exactly advertises this as a feature. Requires OS X 10.6 or later.

Download Here: http://simplemoviex.com/SimpleMovieX/download.html