How to – Turn on Line Numbers in Visual Studio/Express 2010

Background Knowledge


This applies to Microsoft Visual Studio/Express 2010 and as far as I know 2008 as well.

Solution


  1. Go to the menu “Tools” -> “Options”.
  2. In the Options dialog go to “Text Editor” -> “All Languages” or pick a specific language.
  3. On the right hand side under “Display” place a checkmark on “Line Numbers”.
  4. Click on the “OK” button.

Example of a Basic ODBC (MSSQL Server) Query using PHP

An example of a basic ODBC (MSSQL Server/DSN-Less) query using PHP.

Example of Result Set Returning One Row

1
2
3
4
5
6
7
8
9
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers WHERE FooID=777";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
$szLastCheck = odbc_result($rDBRes, "LastCheck");
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Example of Result Set Returning Multiple Rows in an Object

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
while($obRows = odbc_fetch_object($rDBRes))
{
	print $obRows->ColumnName1."<br />";
	print $obRows->ColumnName2."<br />";
	print $obRows->ColumnName3."<br />";
}
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Example of Result Set Returning Multiple Rows in an Array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
while($saRows = odbc_fetch_array($rDBRes))
{
        print $saRows['ColumnName1'];
        print $saRows['ColumnName2'];
        print $saRows['ColumnName3'];
}
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Comments/description of Example

Line #1
Database connection string to define the driver, server host name and database name.
The “server host name” is the server name or IP address of your database server. If your host has multiple instances the “host” value would be formatted like so “foo\bar”. If your using SQL Server Express the “host” name locally would be “.\SQLEXPRESS”.
Line #2-#3
Database login credentilas; username and password.
Line #4
SQL query.
Line #5
Connect to the database defined by Line #1, Line #2 and Line #3.
Line #6
Prepare and execute an SQL statement.
Line #7
Fetch results returned back from the SQL statement. I use a while loop to enumerate through each row of results returned. If you know only one row is going to be returned the while loop is not necessary.
odbc_free_result()
Close database connection.
odbc_close()
Close database connection.

How To – Resolve iTunes App Update Notification

Background Knowledge


The Apple’s iTunes software shows notifications of updates available for apps (applications) for iPhones, iPad and iPod Touch by placing a small numeric value in a box beside “Apps” under “Library” within iTunes. As time goes by it appears this numeric value becomes inaccurate as it reports that there is updates yet when you click on “Updates Available” under “Apps” (bottom right corner) there is no updates or only a few updates that does not add up to what it is reporting is available. It should be noted that though this maybe anonying to some it is not in any way harmful to iTunes or the device.

Solution – One


This issue occurs when one or more apps are purchased using more then one iTunes account. Login to each iTunes account and check for app updates. If there are any then allow the updates to be downloaded and installed. One other option would be to delete the app in iTunes and on the device and then download and install under the preferred iTunes account. In most cases this will resolve the problem.

Solution – Two


Be warned this this step is only necessary if the above does not work. Also be aware the steps below will delete all apps (applications) in your iTunes library. Make sure to have the applications backed up before proceeding.

  1. If the first solution didn’t work try going in iTunes under “Library” -> “Apps”.
  2. Highligh one random application and then select all applications by pressing CTRL-A or click on the menu “Edit” -> “Select All”.
  3. Right mouse click on the an application and click on “Delete” or click on the menu “Edit” -> “Delete”.
  4. Click on the device under “Devices” on the left hand side and then click on “Sync” at the bottom right hand corner.

When the sync is completed all the applications installed on the device will be back in the iTunes Library and the Apps update notification should now be corrected.

How To – Hard Reset a Motorola Q 9H

Warnings

Read and fully understand warnings before continuing further!

  • Doing a hard reset will result in loss of personalized settings and all content stored in phone memory.
  • Ensure your mobile phone has at least 75% battery life before preforming a hard reset. If battery life is too low this may result in damaging the mobile phone.
  • Do not remove battery while preforming a hard reset. Doing so may result in damaging the mobile phone.

Solution

  1. Start with the device turned off. If device is locked and you are not aware of the password remove the battery and then re-install the battery.
  2. Hold down the * and E keys at the same time for 5 seconds while turning on the device.

At this stage you will see a message at the top of the screen and then eventually the entire screen will change while the hard reset is being completed. Be patient, this process can take some time.

How To – Setup Sendmail for Masquerading and as a SMTP Smart Host

Background Knowledge


I have multiple OpenBSD web servers some internal and some public (accessible via the Internet) that uses Sendmail. However on the network there is only one publicly known email server. Therefore I require to Sendmail to function as follows, route all email through an SMTP smart host and when routing mail to the SMTP smart host change the email address hostname (masquerade). For example an email sender of “root@foobar.example.com” would be changed to “root@example.com”.

I’m by no means a Sendmail expert, the steps I explain here is what I’ve learned on my own and with the assistance of Zerberus in IRC Freenode #sendmail channel.

Solution


Alter Sendmail’s configuration file adding the following lines. Refer to Sendmail Configuration Readme for further explanation and How To – Setup Sendmail as a Smart_Host for details on how this process is achieved.

FEATURE(genericstable)dnl
FEATURE(generics_entire_domain)dnl
GENERICS_DOMAIN(`example.com')dnl
MASQUERADE_AS(`example.com')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(`foobar.example.com')dnl
define(`SMART_HOST',`[10.10.15.1]')dnl

You will also need to edit Sendmail’s genericstable as follows. On OpenBSD this is located under “/var/mail/genericstable”.

@foobar.example.com  %1@example.com

Example Configuration File (mc)


divert(-1)
#
# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

#
#  This configuration only runs sendmail on the localhost interface.
#  This allows mail on the local host to work without accepting
#  connections from the net at large.
#

divert(0)dnl
include(`/usr/share/sendmail/m4/cf.m4')dnl
VERSIONID(`@(#)openbsd-localhost-smarthost.mc $Revision: 1.4 $')
OSTYPE(openbsd)dnl
FEATURE(nouucp, `reject')dnl
FEATURE(`accept_unresolvable_domains')dnl
FEATURE(`no_default_msa')dnl
FEATURE(genericstable)dnl
FEATURE(generics_entire_domain)dnl
GENERICS_DOMAIN(`example.com')dnl
MASQUERADE_AS(`example.com')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(`foobar.example.com')dnl
define(`SMART_HOST',`[10.10.15.1]')dnl
DAEMON_OPTIONS(`Family=inet, address=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Family=inet6, address=::1, Name=MTA6, M=O')dnl
DAEMON_OPTIONS(`Family=inet, address=127.0.0.1, Port=587, Name=MSA, M=E')dnl
DAEMON_OPTIONS(`Family=inet6, address=::1, Port=587, Name=MSA6, M=O, M=E')dnl
CLIENT_OPTIONS(`Family=inet6, Address=::')dnl
CLIENT_OPTIONS(`Family=inet, Address=0.0.0.0')dnl
dnl
dnl Some broken nameservers will return SERVFAIL (a temporary failure)
dnl on T_AAAA (IPv6) lookups.
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
MAILER(local)dnl
MAILER(smtp)dnl

Source: How To – Setup Sendmail as a Smart_Host
Source: Sendmail – Masquerading and Relaying
Source: Sendmail Configuration Readme