08.23.07
Having Problems with Star Force running on Vista
I have had a lot of people contact me about having problems with Star Force running on Vista. So I contacted their customer support people. The following steps are their response to my email.
Install the game, a game shortcut is usually created either on the desktop or in the Start menu. Now follow the step below.
1) Right-click on the game’s shortcut, select “Run as administrator”;
2) Run the game;
3) It will ask to reboot the PC;
4) Don’t reboot;
5) Run “sfdrvup.exe” from here: http://www.star-force.com/protection/users ;
6) Reboot.
I have tied the step above on Vista Bussiness and Vista Premium and they work.
08.14.07
Transact-SQL Reserved Keyword – Order By
SQL ORDER BY clause is used to order the data sets retrieved from a SQL database. The ordering of the selected data can be done by one or more columns in a table. If we want to sort our Users table by the FirstName column, we’ll have to use the following ORDER BY SQL statement:
SELECT * FROM Users
ORDER BY FirstName
The result of the ORDER BY statement above will be the following:
| FirstName | LastName | DateOfBirth | City |
| David | Stonewall | 01/03/1954 | San Francisco |
| John | Smith | 12/12/1969 | New York |
| Paul | O’Neil | 09/17/1982 | New York |
| Stephen | Grant | 03/03/1974 | Los Angeles |
| Susan | Grant | 03/03/1970 | Los Angeles |
As you can see the rows are ordered alphabetically by the FirstName column.
You can use ORDER BY to order the retrieved data by more than one column. For example, if you want to order by both LastName and City columns, you would do it with the following ORDER BY statement:
SELECT * FROM Users
ORDER BY LastName, DateOfBirth
Here is the result of this ORDER BY statement:
| FirstName | LastName | DateOfBirth | City |
| Susan | Grant | 03/03/1970 | Los Angeles |
| Stephen | Grant | 03/03/1974 | Los Angeles |
| Paul | O’Neil | 09/17/1982 | New York |
| John | Smith | 12/12/1969 | New York |
| David | Stonewall | 01/03/1954 | San Francisco |
When using ORDER BY with more than one column, you need to separate the list of columns following ORDER BY with commas.What will happen if we reverse the order of the columns specified after the ORDER BY statement like in the statement below?
SELECT * FROM Users
ORDER BY DateOfBirth, LastName
This ORDER BY statement will return the same results as the one with the reversed columns order, but they will be ordered differently. Here is the result:
| FirstName | LastName | DateOfBirth | City |
| David | Stonewall | 01/03/1954 | San Francisco |
| John | Smith | 12/12/1969 | New York |
| Susan | Grant | 03/03/1970 | Los Angeles |
| Stephen | Grant | 03/03/1974 | Los Angeles |
| Paul | O’Neil | 09/17/1982 | New York |
The ORDER BY clause first sorts the retrieved data by the first column, then the next one, and so forth.In all the ORDER BY examples so far, we were sorting alphabetically for character columns (FirstName, LastName) and from earlier to later date for the DateOfBirth column. What do we do if we want to order our data alphabetically but this time backwards? In order to accomplish that we need to use the DESC SQL keyword:
SELECT * FROM Users
ORDER BY FirstName DESC
Here is the result:
| FirstName | LastName | DateOfBirth | City |
| Susan | Grant | 03/03/1970 | Los Angeles |
| Stephen | Grant | 03/03/1974 | Los Angeles |
| Paul | O’Neil | 09/17/1982 | New York |
| John | Smith | 12/12/1969 | New York |
| David | Stonewall | 01/03/1954 | San Francisco |
When you add the keyword DESC after a column name in the ORDER BY clause, you are still ordering by this column but the result is retrieved backwards. The opposite of the DESC keyword is the ASC keyword which orders by the specified columns alphabetically. But how did our previous statements know to order the data alphabetically, when we didn’t specify the ASC keyword? The answer is simple, when you don’t specify ASC or DESC after a column in the ORDER BY column list, then the ordering is done ASC (alphabetically, from low to high) by default.It’s important to remember that whenever you are ordering by more than one column, you need to specify ASC and/or DESC after each column, if you need specific ordering. For example the statement below will order by both LastName and DateOfBirth but only LastName will be in descending order:
SELECT * FROM Users
ORDER BY DateOfBirth, LastName DESC
If you want to order descending by both columns you need to change the ORDER BY statement to this:
SELECT * FROM Users
ORDER BY DateOfBirth DESC, LastName DESC.
Transact-SQL Reserved Keyword – Between
View all sales information between January 6, 1999, and January 10, 1999, in Table Store_Information, Table Store_Information
| store_name | Sales | Date |
| Los Angeles | $1500 | Jan-05-1999 |
| San Diego | $250 | Jan-07-1999 |
| San Francisco | $300 | Jan-08-1999 |
| Boston | $700 | Jan-08-1999 |
we key in,
SELECT *
FROM Store_Information
WHERE Date BETWEEN ‘Jan-06-1999′ AND ‘Jan-10-1999′
Transact-SQL Reserved Keyword – Top
Return only the top 10 rows of a query
SELECT TOP 10 OrderID, CustomerID, EmployeeID, OrderDate
FROM dbo.Orders
WHERE EmployeeID = 5
ORDER BY OrderDate
Transact-SQL Reserved Keyword – SET ROWCOUNT
A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this:
SET ROWCOUNT 10
SELECT * FROM dbo.Orders
WHERE EmployeeID = 5
ORDER BY OrderDate
Transact-SQL Reserved Keyword – Having
HAVING… was added to SQL because the WHERE keyword could not be used against aggregate functions (like SUM), and without HAVING… it would be impossible to test for result conditions. The syntax for the HAVING function is:
SELECT column,SUM(column) FROM table
GROUP BY column
HAVING SUM(column) condition value
|
This “Sales” Table:
| Company | Amount |
| W3Schools | 5500 |
| IBM | 4500 |
| W3Schools | 7100 |
This SQL:
SELECT Company,SUM(Amount) FROM Sales
GROUP BY Company
HAVING SUM(Amount)>10000
|
Returns this result
| Company | SUM(Amount) |
| W3Schools | 12600 |
Transact-SQL Reserved Keyword IF…ELSE
Imposes conditions on the execution of a Transact-SQL statement. The Transact-SQL statement that follows an IF keyword and its condition is executed if the condition is satisfied: the Boolean expression returns TRUE. The optional ELSE keyword introduces another Transact-SQL statement that is executed when the IF condition is not satisfied: the Boolean expression returns FALSE.
Transact-SQL Syntax ConventionsSyntax
IF Boolean_expression { sql_statement | statement_block }
[ ELSE { sql_statement | statement_block } ]
Arguments
Boolean_expression Is an expression that returns TRUE or FALSE. If the Boolean expression contains a SELECT statement, the SELECT statement must be enclosed in parentheses.{ sql_statement | statement_block } Is any Transact-SQL statement or statement grouping as defined by using a statement block. Unless a statement block is used, the IF or ELSE condition can affect the performance of only one Transact-SQL statement. To define a statement block, use the control-of-flow keywords BEGIN and END.
Remarks
An IF…ELSE construct can be used in batches, in stored procedures, and in ad hoc queries. When this construct is used in a stored procedure, it is frequently used to test for the existence of some parameter.IF tests can be nested after another IF or following an ELSE. The limit to the number of nested levels depends on available memory.
ExampleThe following example uses IF…ELSE with output from the uspGetList stored procedure. This stored procedure is defined in Creating Stored Procedures. In this example, the stored procedure returns a list of bikes with a list price less than $700. This causes the first PRINT statement to execute.
DECLARE @compareprice money, @cost money
EXECUTE Production.uspGetList ‘%Bikes%’, 700,
@compareprice OUT,
@cost OUTPUT
IF @cost <= @compareprice
BEGIN
PRINT ‘These products can be purchased for less than $’+RTRIM(CAST(@compareprice AS varchar(20)))+’.’
END
ELSE
PRINT ‘The prices for all products in this category exceed $’+ RTRIM(CAST(@compareprice AS varchar(20)))+’.’
Transact-SQL Reserved Keyword – LIKE
LIKE is another keyword that is used in the WHERE clause. Basically, LIKE allows you to do a search based on a pattern rather than specifying exactly what is desired (as in IN) or spell out a range (as in BETWEEN). The syntax for is as follows:
SELECT “column_name”
FROM “table_name”
WHERE “column_name” LIKE {PATTERN}{PATTERN} often consists of wildcards. Here are some examples:
- ‘A_Z’: All string that starts with ‘A’, another character, and end with ‘Z’. For example, ‘ABZ’ and ‘A2Z’ would both satisfy the condition, while ‘AKKZ’ would not (because there are two characters between A and Z instead of one).
- ‘ABC%’: All strings that start with ‘ABC’. For example, ‘ABCD’ and ‘ABCABC’ would both satisfy the condition.
- ‘%XYZ’: All strings that end with ‘XYZ’. For example, ‘WXYZ’ and ‘ZZXYZ’ would both satisfy the condition.
- ‘%AN%’: All string that contain the pattern ‘AN’ anywhere. For example, ‘LOS ANGELES’ and ‘SAN FRANCISCO’ would both satisfy the condition.
Let’s say we have the following table:Table Store_Information
| store_name | Sales | Date |
| LOS ANGELES | $1500 | Jan-05-1999 |
| SAN DIEGO | $250 | Jan-07-1999 |
| SAN FRANCISCO | $300 | Jan-08-1999 |
| BOSTON | $700 | Jan-08-1999 |
We want to find all stores whose name contains ‘AN’. To do so, we key in,
SELECT *
FROM Store_Information
WHERE store_name LIKE ‘%AN%’ Result:
| store_name | Sales | Date |
| LOS ANGELES | $1500 | Jan-05-1999 |
| SAN DIEGO | $250 | Jan-07-1999 |
| SAN FRANCISCO | $300 | Jan-08-1999 |
Transact-SQL Reserved Keywords
Reserved Keywords
Microsoft® SQL Server™ 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language used by SQL Server to parse and understand Transact-SQL statements and batches. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, this can be done only using delimited identifiers.The following table lists SQL Server reserved keywords.
| ADD | EXCEPT | PERCENT |
| ALL | EXEC | PLAN |
| ALTER | EXECUTE | PRECISION |
| AND | EXISTS | PRIMARY |
| ANY | EXIT | |
| AS | FETCH | PROC |
| ASC | FILE | PROCEDURE |
| AUTHORIZATION | FILLFACTOR | PUBLIC |
| BACKUP | FOR | RAISERROR |
| BEGIN | FOREIGN | READ |
| BETWEEN | FREETEXT | READTEXT |
| BREAK | FREETEXTTABLE | RECONFIGURE |
| BROWSE | FROM | REFERENCES |
| BULK | FULL | REPLICATION |
| BY | FUNCTION | RESTORE |
| CASCADE | GOTO | RESTRICT |
| CASE | GRANT | RETURN |
| CHECK | GROUP | REVOKE |
| CHECKPOINT | HAVING | RIGHT |
| CLOSE | HOLDLOCK | ROLLBACK |
| CLUSTERED | IDENTITY | ROWCOUNT |
| COALESCE | IDENTITY_INSERT | ROWGUIDCOL |
| COLLATE | IDENTITYCOL | RULE |
| COLUMN | IF | SAVE |
| COMMIT | IN | SCHEMA |
| COMPUTE | INDEX | SELECT |
| CONSTRAINT | INNER | SESSION_USER |
| CONTAINS | INSERT | SET |
| CONTAINSTABLE | INTERSECT | SETUSER |
| CONTINUE | INTO | SHUTDOWN |
| CONVERT | IS | SOME |
| CREATE | JOIN | STATISTICS |
| CROSS | KEY | SYSTEM_USER |
| CURRENT | KILL | TABLE |
| CURRENT_DATE | LEFT | TEXTSIZE |
| CURRENT_TIME | LIKE | THEN |
| CURRENT_TIMESTAMP | LINENO | TO |
| CURRENT_USER | LOAD | TOP |
| CURSOR | NATIONAL | TRAN |
| DATABASE | NOCHECK | TRANSACTION |
| DBCC | NONCLUSTERED | TRIGGER |
| DEALLOCATE | NOT | TRUNCATE |
| DECLARE | NULL | TSEQUAL |
| DEFAULT | NULLIF | UNION |
| DELETE | OF | UNIQUE |
| DENY | OFF | UPDATE |
| DESC | OFFSETS | UPDATETEXT |
| DISK | ON | USE |
| DISTINCT | OPEN | USER |
| DISTRIBUTED | OPENDATASOURCE | VALUES |
| DOUBLE | OPENQUERY | VARYING |
| DROP | OPENROWSET | VIEW |
| DUMMY | OPENXML | WAITFOR |
| DUMP | OPTION | WHEN |
| ELSE | OR | WHERE |
| END | ORDER | WHILE |
| ERRLVL | OUTER | WITH |
| ESCAPE | OVER | WRITETEXT |
In addition, the SQL-92 standard defines a list of reserved keywords. Avoid using SQL-92 reserved keywords for object names and identifiers. The ODBC reserved keyword list (shown below) is the same as the SQL-92 reserved keyword list.Note The SQL-92 reserved keywords list sometimes can be more restrictive than SQL Server and at other times less restrictive. For example, the SQL-92 reserved keywords list contains INT, which SQL Server does not need to distinguish as a reserved keyword.Transact-SQL reserved keywords can be used as identifiers or names of databases or database objects, such as tables, columns, views, and so on. Use either quoted identifiers or delimited identifiers. The use of reserved keywords as the names of variables and stored procedure parameters is not restricted. For more information.
ODBC Reserved Keywords
The following words are reserved for use in ODBC function calls. These words do not constrain the minimum SQL grammar; however, to ensure compatibility with drivers that support the core SQL grammar, applications should avoid using these keywords.This is the current list of ODBC reserved keywords. For more information, see Microsoft ODBC 3.0 Programmer’s Reference, Volume 2, Appendix C.
| ABSOLUTE | EXEC | OVERLAPS |
| ACTION | EXECUTE | PAD |
| ADA | EXISTS | PARTIAL |
| ADD | EXTERNAL | PASCAL |
| ALL | EXTRACT | POSITION |
| ALLOCATE | FALSE | PRECISION |
| ALTER | FETCH | PREPARE |
| AND | FIRST | PRESERVE |
| ANY | FLOAT | PRIMARY |
| ARE | FOR | PRIOR |
| AS | FOREIGN | PRIVILEGES |
| ASC | FORTRAN | PROCEDURE |
| ASSERTION | FOUND | PUBLIC |
| AT | FROM | READ |
| AUTHORIZATION | FULL | REAL |
| AVG | GET | REFERENCES |
| BEGIN | GLOBAL | RELATIVE |
| BETWEEN | GO | RESTRICT |
| BIT | GOTO | REVOKE |
| BIT_LENGTH | GRANT | RIGHT |
| BOTH | GROUP | ROLLBACK |
| BY | HAVING | ROWS |
| CASCADE | HOUR | SCHEMA |
| CASCADED | IDENTITY | SCROLL |
| CASE | IMMEDIATE | SECOND |
| CAST | IN | SECTION |
| CATALOG | INCLUDE | SELECT |
| CHAR | INDEX | SESSION |
| CHAR_LENGTH | INDICATOR | SESSION_USER |
| CHARACTER | INITIALLY | SET |
| CHARACTER_LENGTH | INNER | SIZE |
| CHECK | INPUT | SMALLINT |
| CLOSE | INSENSITIVE | SOME |
| COALESCE | INSERT | SPACE |
| COLLATE | INT | SQL |
| COLLATION | INTEGER | SQLCA |
| COLUMN | INTERSECT | SQLCODE |
| COMMIT | INTERVAL | SQLERROR |
| CONNECT | INTO | SQLSTATE |
| CONNECTION | IS | SQLWARNING |
| CONSTRAINT | ISOLATION | SUBSTRING |
| CONSTRAINTS | JOIN | SUM |
| CONTINUE | KEY | SYSTEM_USER |
| CONVERT | LANGUAGE | TABLE |
| CORRESPONDING | LAST | TEMPORARY |
| COUNT | LEADING | THEN |
| CREATE | LEFT | TIME |
| CROSS | LEVEL | TIMESTAMP |
| CURRENT | LIKE | TIMEZONE_HOUR |
| CURRENT_DATE | LOCAL | TIMEZONE_MINUTE |
| CURRENT_TIME | LOWER | TO |
| CURRENT_TIMESTAMP | MATCH | TRAILING |
| CURRENT_USER | MAX | TRANSACTION |
| CURSOR | MIN | TRANSLATE |
| DATE | MINUTE | TRANSLATION |
| DAY | MODULE | TRIM |
| DEALLOCATE | MONTH | TRUE |
| DEC | NAMES | UNION |
| DECIMAL | NATIONAL | UNIQUE |
| DECLARE | NATURAL | UNKNOWN |
| DEFAULT | NCHAR | UPDATE |
| DEFERRABLE | NEXT | UPPER |
| DEFERRED | NO | USAGE |
| DELETE | NONE | USER |
| DESC | NOT | USING |
| DESCRIBE | NULL | VALUE |
| DESCRIPTOR | NULLIF | VALUES |
| DIAGNOSTICS | NUMERIC | VARCHAR |
| DISCONNECT | OCTET_LENGTH | VARYING |
| DISTINCT | OF | VIEW |
| DOMAIN | ON | WHEN |
| DOUBLE | ONLY | WHENEVER |
| DROP | OPEN | WHERE |
| ELSE | OPTION | WITH |
| END | OR | WORK |
| END-EXEC | ORDER | WRITE |
| ESCAPE | OUTER | YEAR |
| EXCEPT | OUTPUT | ZONE |
| EXCEPTION |
Future Keywords
The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers.
| ABSOLUTE | FOUND | PRESERVE |
| ACTION | FREE | PRIOR |
| ADMIN | GENERAL | PRIVILEGES |
| AFTER | GET | READS |
| AGGREGATE | GLOBAL | REAL |
| ALIAS | GO | RECURSIVE |
| ALLOCATE | GROUPING | REF |
| ARE | HOST | REFERENCING |
| ARRAY | HOUR | RELATIVE |
| ASSERTION | IGNORE | RESULT |
| AT | IMMEDIATE | RETURNS |
| BEFORE | INDICATOR | ROLE |
| BINARY | INITIALIZE | ROLLUP |
| BIT | INITIALLY | ROUTINE |
| BLOB | INOUT | ROW |
| BOOLEAN | INPUT | ROWS |
| BOTH | INT | SAVEPOINT |
| BREADTH | INTEGER | SCROLL |
| CALL | INTERVAL | SCOPE |
| CASCADED | ISOLATION | SEARCH |
| CAST | ITERATE | SECOND |
| CATALOG | LANGUAGE | SECTION |
| CHAR | LARGE | SEQUENCE |
| CHARACTER | LAST | SESSION |
| CLASS | LATERAL | SETS |
| CLOB | LEADING | SIZE |
| COLLATION | LESS | SMALLINT |
| COMPLETION | LEVEL | SPACE |
| CONNECT | LIMIT | SPECIFIC |
| CONNECTION | LOCAL | SPECIFICTYPE |
| CONSTRAINTS | LOCALTIME | SQL |
| CONSTRUCTOR | LOCALTIMESTAMP | SQLEXCEPTION |
| CORRESPONDING | LOCATOR | SQLSTATE |
| CUBE | MAP | SQLWARNING |
| CURRENT_PATH | MATCH | START |
| CURRENT_ROLE | MINUTE | STATE |
| CYCLE | MODIFIES | STATEMENT |
| DATA | MODIFY | STATIC |
| DATE | MODULE | STRUCTURE |
| DAY | MONTH | TEMPORARY |
| DEC | NAMES | TERMINATE |
| DECIMAL | NATURAL | THAN |
| DEFERRABLE | NCHAR | TIME |
| DEFERRED | NCLOB | TIMESTAMP |
| DEPTH | NEW | TIMEZONE_HOUR |
| DEREF | NEXT | TIMEZONE_MINUTE |
| DESCRIBE | NO | TRAILING |
| DESCRIPTOR | NONE | TRANSLATION |
| DESTROY | NUMERIC | TREAT |
| DESTRUCTOR | OBJECT | TRUE |
| DETERMINISTIC | OLD | UNDER |
| DICTIONARY | ONLY | UNKNOWN |
| DIAGNOSTICS | OPERATION | UNNEST |
| DISCONNECT | ORDINALITY | USAGE |
| DOMAIN | OUT | USING |
| DYNAMIC | OUTPUT | VALUE |
| EACH | PAD | VARCHAR |
| END-EXEC | PARAMETER | VARIABLE |
| EQUALS | PARAMETERS | WHENEVER |
| EVERY | PARTIAL | WITHOUT |
| EXCEPTION | PATH | WORK |
| EXTERNAL | POSTFIX | WRITE |
| FALSE | PREFIX | YEAR |
| FIRST | PREORDER | ZONE |
| FLOAT | PREPARE |
Creating a New database for a Mobile Applications, using Visual Studio 2005
Adding database file (SQL compact edition)
· Right click on the mobile project you want to add to project.
· Select add -> new item.
· Select Database file.
· Name the file. (Note the .sdf extension for a SQL compact database file), then click Add.
· Next the Data Source Configuration Wizard will show.
· Click on the Finish button. You do not need to select Tables or Views as it is a new database and there aren’t any.
If you look in Solution Explorer you will see the database file and the dataset file that you add. Now we need to create the tables.
Add a table to new database
· In Server Explorer pane, click on the plus sign to view the children folders.
· Right click on the Tables folder and select Create Table. This will open up a wizard.
· Name the table.
· Add the columns you need in the table and click the OK button. You will notice the table in the Server Explorer.
Add table to Dataset
· Double click on the Dataset in the Solution Explorer.
· Drag the table from Server Explorer to the dataset canvas (datasetname.xsd). You will see the table on the canvas with a table adapter.
Add a Query to Dataset
Note that Sql compact edition does not allow you to create a stored procedure or function in the database like you can will a normal sql database file, which is the best way.
· Right click on the table you want to add the query to
· Select Add -> Query
· In the wizard select Use SQL statement option
· Choose the Query Type you would like to add.
· If you know SQL, you can type it in the textbox, or
· Click on the query builder button to access the Query Builder wizard.
· To add a table right click on the top panel in the wizard and select the Add table option, then select the table you want.
· Once you have created the query click on the OK button.
· Click next and name the query (method). Fill is used to fill a dataset table, e.g. ClientTableAdapter.Fill(appDataSet.ClientTable). While return a Data table will return the query result as a table e.g. ClientTable clinttable = ClientTableAdapter.GetDataBy()
· Click Finish
Some Advise
Plan your data structures well as it is a pain to add fields after you have created the database, dataset and all your queries. It is not just a case of adding the field to the database. The dataset and queries will need to be updated as well.