Friday, December 3, 2010

ASP.NET Datasets: Failed to enable constraints.

Got this error after changing the length of a column in the database:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

CAUSE:
The table adapter column maxlength is not updated automatically.

SOLUTION:
Update the table adapter column maxlength manually in the properties window for that column in the dataset editor.

Source:
http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1

Wednesday, November 17, 2010

SQL SERVER – Fix : Error: 4064

SQL SERVER 2005 – Fix : Error: 4064 – Cannot open user default database. Login failed. Login failed for user.

CAUSE:
The default database for the user is not accessible, this stops the user from logging in.

SOLUTION:
- Login Prompt->Connection Properties Tab->Connect to database field
- Change the database name to master.
- Once logged in, update the user's default database:

ALTER LOGIN [user] WITH DEFAULT_DATABASE = master

Source:
http://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/

Tuesday, September 14, 2010

Using LINQ to get a Distinct List

First, create a type comparer:

    public class ItemComparer : IEqualityComparer<Item>
    {
        #region IEqualityComparer<Item> Members
 
        public bool Equals(Item x, Item y)
        {
            return x.ItemID == y.ItemID;
        }
 
        public int GetHashCode(Item obj)
        {
            return obj.ItemID.GetHashCode();
        }
        #endregion
    } 


Then, use it as follows on a List items:

    IEnumerable<Item> distinctItems = 
          items.Distinct(new ItemComparer());
    items = distinctItems.ToList();

Monday, August 30, 2010

Android - Why not to use a task killer

Looks like task killers on android are not recommended:

- By killing an app with a task killer, you remove the state information for that app, meaning the app has to be opened fully the next time you use it, instead of loading from where it was, thus using more battery.
- It also leads to possible instability by killing processes that may be shared by different apps.
- Android is smart enough to handle memory allocation.

via Droid Den:
http://www.droid-den.com/android-guides/android-guide-should-i-use-a-task-killer

Tuesday, June 22, 2010

ASP.NET Login control styles & properties

Properties of the Login Control
TitleText Indicates the text to be displayed in the heading of the control.
InstructionText Indicates the text that appears below the heading of the control.
UserNameLabelText Indicates the label text of the username text box.
PasswordLabelText Indicates the label text of the password text box.
FailureText Indicates the text that is displayed after failure of login attempt.
UserName Indicates the initial value in the username text box.
LoginButtonText Indicates the text of the Login button.
LoginButtonType Button/Link/Image. Indicates the type of login button.
DestinationPageUrl Indicates the URL to be sent after login attempt successful.
DisplayRememberMe true/false. Indicates whether to show Remember Me checkbox or not.
VisibleWhenLoggedIn true/false. If false, the control is not displayed on the page when the user is logged in.
CreateUserUrl Indicates the url of the create user page.
CreateUserText Indicates the text of the create user link.
PasswordRecoveryUrl Indicates the url of the password recovery page.
PasswordRecoveryText Indicates the text of the password recovery link.

Style of the Login Control
CheckBoxStyle Indicates the style property of the Remember Me checkbox.
FailureStyle Indicates the style property of the failure text.
TitleTextStyle Indicates the style property of the title text.
LoginButtonStyle Indicates the style property of the Login button.
TextBoxStyle Indicates the style property of the TextBox.
LabelStyle Indicates the style property of the labels of text box.
HyperLinkStyle Indicates the style property of the hyperlink in the control.
InstructionTextStyle Indicates the style property of the Instruction text that appears below the heading of the control.
Events of the Login Control
LoggingIn Fires before user is going to authenticate.
LoggedIn Fires after user is authenticated.
LoginError Fires after failure of login attempt.
Authenticate Fires to authenticate the user. This is the function where you need to write your own code to validate the user.

Thanks to: http://www.dotnetfunda.com/tutorials/controls/login.aspx

Photos from the Gulf of Mexico oil spill

Amazing photos from the Gulf of Mexico oil spill:



http://www.boston.com/bigpicture/2010/06/oil_in_the_gulf_two_months_lat.html

Saturday, June 19, 2010

Quick Launch toolbar in Windows 7

To add the QuickLaunch toolbar in Windows 7:

Solution:

- Right-click on taskbar: Toolbars > New Toolbar
- Enter the following path: %userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
- Click Select Folder
- Right-click the Windows 7 Taskbar again and select Lock The Taskbar from the menu to move to desired position.

Thanks to
http://windows7news.com/2009/01/29/enable-windows-7-quick-launch-toolbar/

Wednesday, June 16, 2010

IIS Error - The tracking (workstation) service is not running

This morning, the IIS website decided to stop, and on attempted restart displayed:

Error:

The tracking (workstation) service is not running

Solution:

CMD Line: net start httpfilter
CMD Line: iisreset

Thanks to : http://thejimboeffect.blogspot.com/2007/02/mserror-tracking-workstation-service-is.html

Wednesday, May 26, 2010

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Came across this error with a SQL Server 2005 sproc, being called via a Visual Studio 2008 xsd table adapter.


Solution: 
Check your data adapter tables, the sproc was missing 2 columns that the datatable was expecting in the results:


http://social.msdn.microsoft.com/forums/en-US/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1/