2011/02/24

Simple Lesson : Copy some or all fields value, from a table into new table

You can create backup table for all fields or some fields with SQL Query.
This Query very useful for backup table without a lot of code.But there is rule you must follow,destination table must new table,not same with another table in database.

Syntax Code :

SELECT [fields] INTO [destination table] FROM [source table] where [condition]

SELECT [fields] INTO [destination table] IN [database file] FROM [source table] where [condition]

Consider the following example:

1. If you wan copy all fields form a table to another table
SELECT * INTO EmployeeBackup FROM Employee where status= 'Manager'

2. If you want copy some fields from a table to another table
SELECT Name,Contract INTO EmployeeBackup FROM Employee where status= 'Manager'

3. If you want copy fields to another database
SELECT * INTO EmployeeBackup IN 'backup.MDB' FROM Employee where status= 'Manager'

Simple Lesson : Insert Field value from another table Query

We can move a number of field values from one table to another table, but the number columns and their data types must match.

example :

1. We Have one table with some field like this :

Table : employee
Field : name,contract,status

2.We have another table like this :

Table : manager
Field : name, contract.

3. First step we insert value to Employee table

Insert employee (name,contract,status)
values ('Billy','10 Years','Senior')

4. Second step we insert value from employee table which status Senior

Insert manager (name,contract)
select name,contract from employee
where status = 'Senior'

2011/02/22

Simple lesson VB.net: Chr in VB.net

We can using Chr function in Vb 6.0 to convert ASCII value to char.
We can using Chr like this in Vb 6.0 :

Dim character As String
character = Chr(97)
This Result is "a".

For the same function in VB.net we can using toChar.
We can using toChar function like this in Vb.net :

Dim character As String
character = Convert.ToChar(97)
This Result is "a"