29 May 2008

How do I clear (onclick) and restore (onblur) the default value for a text field?

Below is one example of how to clear the default text of a text field. In this example, the default text is: “Search Keywords”. If the user types text into the field, their entry will remain, allowing them the opportunity to click your “Search” button (or do whatever else is planned). However, if the user simply clicks into the field then clicks elsewhere (onblur), the default text will be returned.
<asp:TextBox ID="TextBox1" runat="server" class="searchfield" Text="Search Keywords"
onfocus="if(this.value=='Search Keywords')(this.value='');" onblur="if(this.value=='')(this.value='Search Keywords');" />
Essentially, the JavaScript reads like this: When the onclick event occurs, if the text in the text box is equal to: “Search Keywords”, set the text in the text box to nothing. When the onblur event occurs, if the text in the text box is nothing, set it to: “Search Keywords”.

For additional information on JavaScript events, please visit: http://www.irt.org/articles/js058/.

14 May 2008

How do I determine which version of Ubuntu I am using?

  1. From the desktop, select: Applications > Accessories > Terminal. A command-line terminal window will open.
  2. At the terminal prompt, type: lsb_release -a then press Enter.
  3. Information about your installation will be displayed.

Rhythmbox stopped playing my MP3s. How do I fix it?

  1. Select: System > Preferences > Sound.
  2. Set all Sound Playback dropdowns to: ALSA - Advanced Linux Sound Architecture.
  3. Click: Close.
  4. Exit Rhythmbox by selecting: File > Quit.
  5. Launch Rhythmbox.

21 February 2008

How do I set the default value or binding to a date in the future?

In this article, we will be using SQL Server's Default Value or Binding property to set the default column value to a date in the future. This can be useful if you have a value that you want to expire on a specific date from it's creation.
  1. From SQL Server Management Studio, right-click on the target table and select Modify.
  2. Select the desired column in Object Explorer then move down to the Column Properties section.
  3. In the Default Value or Binding field, enter: (dateadd(year, 30, getdate())) This sets the value to 30 years from the date that the record is entered (unless a value is actually specified during entry).
  4. Save your changes.
  5. You may of course, use different timespans by simply modifying dateadd. For more information, try Google.

08 January 2008

How do I install the AdventureWorks sample database with SQL Server 2005 Express?

File Download:

  1. Navigate to: http://www.codeplex.com/MSFTDBProdSamples.
  2. From the: Releases tab, click: SQL Server 2005 (hyperlink).
  3. Scroll down and click: AdventureWorksLT.msi.
  4. Save the file to your desktop or other known location.
  5. Once the download is complete, click: Run (or navigate to the location where you saved the file and double-click: AdventureWorksLT.msi) to start the install.
  6. Follow the prompts (using the default selections) to complete the install.

DB Permissions Configuration:

  1. From the keyboard, press: Windows Key + E to launch Windows Explorer.
  2. In Windows Explorer, navigate to: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data.
  3. Right-click: AdventureWorksLT_Data.mdf then select: Properties.
  4. Click: Security > Edit > Add.
  5. Type your login name into the: Enter the object names... textbox then click: Check Names. Your entry will automatically resolve to: MACHINENAME\Login.
  6. Click: OK.
  7. Select your login name from the: Groups or usernames list.
  8. In the: Permissions for LoginName box, click: Full control then click: OK > OK. You should now be back at the Windows Explorer window.
  9. Right-click: AdventureWorksLT_Log.ldf then repeat this process to change the user permissions for that file as well.

SQL Server Management Studio Configuration:

  1. Launch Microsoft SQL Server Management Studio Express and connect to your local server. Ensure that the default connection settings are used.
  2. From Object Explorer, right-click: Databases then click: Attach. The: Attach Databases dialog will appear.
  3. Click: Add.
  4. Click: AdventureWorksLT_Data.mdf then click: OK.
  5. Click: OK. You should now be at the main window for: Microsoft SQL Server Management Studio Express.
  6. In Object Explorer, expand: Databases > AdventureWorksLT > Tables.
  7. Right-click: dbo.BuildVersion then select: Script Table as > SELECT to > New Query Editor Window.
  8. Press: F5. The query will return the build version, confirming a successful installation.

Possible Problems:

Error: The database 'AdventureWorks' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported. Could not open new database...

Error: Error 27506. Error executing SQL script sqlscript.sql. Line 17. The database 'AdventureWorksLT' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported (948)...

These errors are generated when you attempt to install AdventureWorks for SQL Server 2008 on SQL Server 2005. The CodePlex website contains two versions of the database: One for SQL Server 2005 and one for SQL Server 2008. Repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: Error 1722.There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel...

This error is also generated after attempting to install AdventureWorks for SQL Server 2008 on SQL Server 2005, though this error code may be specific to a Windows XP installation. Either way, repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: CREATE File encountered operating system error 5(access denied) while attempting to open/create the file.... MS SQL error 5123...

This error (or similar) is related to file permissions for: AdventureWorksLT_Data.mdf and/or AdventureWorksLT_Log.ldf. In either case, repeat the: DB Permissions Configuration: portion of this tutorial.

How do I minimize iTunes to the Task Bar?

To send iTunes to the Windows Task Bar when minimized:

  1. From the desktop, right-click on an empty portion of the Task Bar then select Properties.
  2. Select the Toolbars tab then enable the iTunes toolbar.
  3. Click: OK. With this option enabled, iTunes will minimize to the Task Bar (near the notification area).

How do I prevent a program from starting when Windows boots?

Method 1

  1. Select: Start > All Programs > Startup.
  2. Locate the desired program then right-click on the name and select Delete. Note: This will not delete the actual program, it simply removes it from the Startup folder.
  3. Restart your computer.

If the program is not listed in the Startup folder...

Method 2

  1. Click: Start then type: system.
  2. Click: System Configuration in the Programs list.
  3. From the Startup tab, disable the desired program by removing it's check from the Startup Item column. Note: Take care when disabling items in the System Configuration window. Some of these items may be required for proper system function.
  4. Restart your computer.

If you are still unable to locate the desired program:

Method 3

  1. Try AutoRuns.

How do I organize and import my music library into iTunes (v7.5)?

  1. To avoid confusion, close or minimize all open applications.
  2. Open 1 Windows Explorer window by pressing: Windows Key + E.
  3. Navigate to the directory containing your existing music library.
  4. Launch iTunes.
  5. From the iTunes menu bar, select: Edit > Preferences > Advanced > General.
  6. Enable the options titled: Keep iTunes Music folder organized and: Copy files to iTunes Music folder when adding to library.
  7. Click: OK. The first option (Keep iTunes Music...) provides the organized folder structure and file naming, while the second option (Copy files to...) creates a copy in the default iTunes Music directory (mine is: C:\Users\AbleBaker\Music\iTunes\iTunes Music).
  8. Return to your Windows explorer session and begin to drag-and-drop your music files / folders into the iTunes player. Unless you intend to leave your computer alone for a few minutes is a good idea to transfer a relatively small number of files / folders at each pass as it may slow the system considerably.
  9. Your library is now organized and imported. Since the files were actually copied into the iTunes folder, you could safely choose to delete your old music directory.

06 January 2008

How do I select the name for a day of the week?

Selecting the name for a day of the week is fairly straight forward using the DATENAME function and a DATEPART argument. For example:

SELECT DATENAME(weekday, GETDATE()) AS 'MyDay';
returns:

MyDay
------
Sunday

We could also use DATENAME to obtain the name of a month:

SELECT DATENAME(month, GETDATE()) AS 'MyMonth';
Which returns:

MyDay
-------
January

For additional information, please visit: http://msdn2.microsoft.com/en-us/library/ms174395.aspx

How do I select only the date from a datetime data type?

Selecting only the date portion from a datetime data type could be accomplished in a number of ways. One of the most convenient methods is to simply use CONVERT and one of the many style values.

SELECT GETDATE() AS MyDate
returns the default format:

MyDate
-----------------------
2008-01-06 19:39:15.410

However, buy using CONVERT and applying a particular style value, we are able to achieve the desired result. For example:

SELECT CONVERT(VARCHAR(10),GETDATE(),126) AS MyDate
returns:

MyDate
----------
2008-01-06

Another style example:

SELECT CONVERT(VARCHAR(10),GETDATE(),101) AS MyDate
returns:

MyDate
----------
01/06/2008

For additional information, visit: http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx

05 January 2008

How do I concatenate characters or strings using SQL?

Concatenation (joining 2 or more characters or strings of the same data type) is accomplished using the "+" operator. For example, let's say that I want to join the strings "Able" and "Baker". To do so, I would simply write:

select 'Windows' + 'Vista' as OSName
Running this query would return:

OSName
------------
WindowsVista

OK so far, but what if you want a space between "Windows" and "Vista"? That could be accomplished in 2 ways: Either by including it in one of our existing strings (i.e. "Windows " or " Vista"), as in:

select 'Windows ' + 'Vista' as OSName
or by adding an additional concatenation operator:

select 'Windows' + ' ' + 'Vista' as OSName
Both methods return the desire result:

OSName
-------------
Windows Vista

A more useful example that also demonstrates the "of the same data type" caveat mentioned above:

select 'Today is: ' + convert(varchar(10), getdate(), 101) as Today
would return:

Today
--------------------
Today is: 01/05/2008

However, if we failed to convert result of getdate() into a varchar, we would receive an error similar to:

Today
----------------------
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting datetime from character string.

For additional information, please visit: http://msdn2.microsoft.com/en-us/library/ms177561.aspx

How do I determine whether I am running the 32-bit or 64-bit version of Windows Vista?

Method 1:

  1. From the keyboard, press: Windows Key + R. The Run dialog will display.
  2. Type: control then press Enter. The Control Panel will display.
  3. Double-click: System (in Classic view) - or- System and Maintenance > System (in the Control Panel Home view).
  4. In the right pane, locate System Type.
    • 32-bit version will show either: 32-bit Operating System -or- x86-based PC
    • 64-bit version will show either: 64-bit Operating System -or- x64-based PC

Method 2:

  1. From the keyboard, press: Windows Key then type: system.
  2. From the Programs list, click: System Information. The System Information window will display.
  3. Click: System Symmary (if not already selected) in the left pane.
  4. In the right pane, locate System Type.
    • 32-bit version will show either: 32-bit Operating System -or- x86-based PC
    • 64-bit version will show either: 64-bit Operating System -or- x64-based PC

How do I configure Windows Update - Windows Vista

  1. From the keyboard, press: Windows Key + R. The Run dialog will display.
  2. Type: control then press Enter. The Control Panel will display.
  3. Double-click: Windows Update (in Classic view) - or- System and Maintenance > Windows Update (in the Control Panel Home or Category view).
  4. In the left pane, click: Change Settings.
  5. Make the desired changes then click: OK.

04 January 2008

How do I uninstall programs - Windows Vista?

  1. Close all open applications.
  2. From the desktop, press: Windows Key + R to display the Run dialog.
  3. Type: "control" then press Enter. The Control Panel will display.
  4. Double-click: Programs and Features. A list of the currently installed programs will be displayed.
  5. Left-click the desired program then click Uninstall.
  6. Follow the prompts to remove the program from your system.
    * Though not normally required, it is often a good idea to restart your computer once the uninstallation is complete.
  7. Congratulations, you have successfully uninstalled a program from Windows Vista.

How do I change the Start menu to Classic (XP/2000) view - Windows Vista?

  1. From the desktop, right-click on an empty portion of the Task Bar then click Properties.
  2. Select the Start Menu tab.
  3. Click the Classic Start menu option then click OK.
  4. The Start menu will now appear as it did in previous versions of Windows.

How do I access the Run dialog - Windows Vista?

  1. From the keyboard, press: Windows Key + R. The Run dialog will be displayed.

How do I change the Control Panel to Classic (XP/2000) view - Windows Vista?

  1. From the keyboard, press: Windows Key + R. The Run dialog will display.
  2. Type: control then press Enter. The Control Panel will display.
  3. In the left pane, click Classic View. To return to the default category view, simply repeat #1 and #2 then click Control Panel Home.

How do I disable the clicking sounds when new Web pages load in Internet Explorer - Windows Vista?

  1. From the keyboard, press: Windows Key + R. The Run dialog will display.
  2. Type: control then press Enter. The Control Panel will display.
  3. Double-click: Sound (in Classic view) - or- Hardware and Sound followed by: Sound (in the Control Panel Home or Category view).
  4. Click the Sounds tab then scroll down and locate: Start Navigation. Left-click Start Navigation to select it.
  5. From the Sounds pulldown, click: (None).
  6. Click OK.

How do I prevent open Internet Explorer windows from being reused when I click links - Windows Vista?

  1. From the keyboard, press: Windows Key + R. The Run dialog will display.
  2. Type: control then press Enter. The Control Panel will display.
  3. Double-click: Internet Options (in Classic view) - or- Network and Internet followed by: Internet Options (in the Control Panel Home or Category view). The Internet Properties window is displayed.
  4. Click the Advanced tab.
  5. Scroll down and locate: Reuse windows for launching shortcuts.
  6. Disable this option by clearing the checkbox.
  7. Click OK then close the Control Panel.