Look at the case study VFP: Create a table with SQL command

Source: Internet
Author: User
Tags exit in table name

This article is an example of using SQL command to create a table in VFP. The format for creating a table structure with SQL commands is as follows:

CREATE TABLE table name (field name 1 type (width [, decimal places]), field Name 2 type (width [, decimal places]),...)

In looking at the example of VFP: The sample database has given the table structure of the website information table as follows:

Field name Type Width
Number Character type 5
Site name Character type 12
Website Web site Character type 24

So I'm going to create the same table structure and the SQL commands with the table named "Web Information Table 2" are as follows:

CREATE TABLE Web site Information Table 2 (number C (5), website name C (12), website URL C (24))

The main operation of this example is done in the Init event of the form. In this event, you first create the table structure of Web Information table 2 by using the SQL command, and then append all the records from the site information table to the Site Information table 2 and set the site Information table 2 as the data source for the table control grid1. This table shows the "Site Information table 2" data, at this time you open the working directory you can see this "Site Information table 2", and finally on the exit in the form of the Unload event to delete the "Web site Information Table 2" we created. The interface is as follows:

The production steps are as follows:

First, create a new form and set its Caption property value to "Programming Portal-Create a table with SQL Commands", and the width and height property values are set to. T., save the form as "CREATE table with sql command. Scx".

Add a Table control grid1 to the form and set its RecordSourceType property value to "1-alias", ReadOnly property value to. T.

Third, add the event code:

1. Init event code for the form:

CREATE TABLE Web site Information Table 2 (number C (5), Site name C (12), Web Site C ())
append from site information table go top
this.grid1.recordsource= Website Information Table 2 "

2. Unload event code for the form:

Close all
Delete file Web site information table 2.dbf
if file ("Web site Information table 2.") BAK ")
   Delete file Web site Information table 2. BAK
endif

Run "CREATE table with sql command. Scx".

This example code is debugged in the win2003+vfp6.0 environment.

See the full set of "rookie also learn VFP" tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.