Monday, February 21, 2011

USB devices attached to this computer has malfunctioned

This problem drove my IT support nuts, but there is a simple way 5 steps process to resolve the problem:

1. Disconnect all USB devices from the computer.
2. Go to BIOS and set USB as the 1st to load. This will make sure the device driver is loaded before Windows start.
3. Go to Windows in Safe mode - this will load all the device drivers again.
4. Switch off your computer for 30 mins so that the last faulty USB error memory that is stored in BIOS is cleared.
5. Restart your computer.


This works for all the cases of this problem I have found so far.

Thursday, August 26, 2010

Saving Changes is not Permitted. The changes you made requires the table to be dropped and recreated...

One of the new things that happens in SQL Server 2008 is that it prevents saving table structure changes that require the table to be dropped and re-created. While this is a great feature to prevent accidents from occurring, on a developer machine it can be quite frustrating. This is the dialog you get when trying to make changes in a table design.



Unfortunately, this dialog doesn’t tell you where to turn this feature off! Clicking on the small “?” on the title bar does get you to a help page that tells you how to do it.

Anyway, the place to do it is Tools > Options > Designers > Table and Database Designers > Prevent saving changes that require table re-creation. Turn this option off and you will be able to save the tables again.

Thursday, May 28, 2009

SQL Server 2005: Importing from Excel error 0xc020901c

Error 0xc020901c: Data Flow Task: There was an error with output column "Agenda 2" (63) on output "Excel Source Output" (9). The column status returned was: "Text was truncated or one or more characters had no match in the target code page.".


To fix the problem

  • To change the value of TypeGuessRows, use these steps:
  • On the Start menu, click Run. In the Run dialog box, type Regedt32, and then click OK.
  • Open the following key in the Registry editor:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel
  • Double-click TypeGuessRows.
  • In the DWORD editor dialog box, click Decimal under Base. Type a value between 0 
  • Click OK, and then exit the Registry Editor.

http://support.microsoft.com/kb/281517/EN-US/

Wednesday, May 13, 2009

How to Close Web Browsers

btn.Attributes.Add("OnClick", "self.close()");
will do the trick.
Another alternative is
Response.Write (" < script > self.close() ; < /script >
");

Wednesday, April 22, 2009

DataBase could not be exclusively Locked when renaming a database

The problem is due to other users using the database. To resolve the problem, you set the database to be used only by yourself. After the rename operation, you need to reset it back to be usable by other users. It is a common courtesy to inform all users prior to doing this operation.

ALTER DATABASE DBNAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
SP_RENAMEDB @dbname = 'old_name' ,
@newname = 'new_name'
Go
ALTER DATABASE NEWDBNAME SET MULTI_USER -- set back to multi user
GO

Monday, March 16, 2009

How to Sort or handle Paging in GridView Manually without databinding

The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled.
The GridView 'GridViewID' fired event Sorting which wasn't handled.

private string ConvertSortDirectionToSql(SortDirection sortDirection)
{
string newSortDirection = String.Empty;

switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;

case SortDirection.Descending:
newSortDirection = "DESC";
break;
}

return newSortDirection;
}

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
GridViewSortExpression = e.SortExpression;
int pageIndex = this.GridView1.PageIndex;
this.GridView1.DataSource = SortDataTable(GridView1.DataSource as DataTable, false);
this.GridView1.DataBind();
this.GridView1.PageIndex = pageIndex;

}

private string GridViewSortDirection
{
get
{
return ViewState["SortDirection"] as string ?? "ASC";
}

set
{
ViewState["SortDirection"] = value;
}
}



private string GridViewSortExpression
{
get
{
return ViewState["SortExpression"] as string ?? string.Empty;
}
set
{
ViewState["SortExpression"] = value;
}
}



private string GetSortDirection()
{
switch (GridViewSortDirection)
{
case "ASC":
GridViewSortDirection = "DESC";
break;
case "DESC":
GridViewSortDirection = "ASC";
break;
}
return GridViewSortDirection;
}



protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.DataSource = SortDataTable(this.GridView1.DataSource as DataTable, true);
this.GridView1.PageIndex = e.NewPageIndex;
this.GridView1.DataBind();
}

protected DataView SortDataTable(DataTable dataTable, bool isPageIndexChanging)
{
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
if (GridViewSortExpression != string.Empty)
{
if (isPageIndexChanging)
{
dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection);
}
else
{
dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GetSortDirection());
}
}
return dataView;
}

else
{
return new DataView();
}
}

How to have Display Number in GridView

< asp:TemplateField >
< ItemTemplate >
< %# Container.DataItemIndex + 1 % >
< /ItemTemplate >
< /asp:TemplateField >

Tuesday, March 10, 2009

Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started..

The error that you are getting is because your StateServer is not enabled. You have to go to AdministrativeTools > Computer Management > Services and Applications >Services and start the ASP.NET State Service

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported...

This problem frequently occurs when you just restored a database, but service brokers are broken or lost.

To resolve this problem.

alter database xxxx set NEW_BROKER

Alternatively,

1. Go to Programs -> Microsoft Sql Server 2005 -> Configuration Tools -> Sql Server Surface Area Configuration -> Surface Area Configuration for Features.
2. Locate "Service Broker" under the database engine and enable it.