Home > Software engineering >  In a table adds a numeric fields, how to assign a different value
In a table adds a numeric fields, how to assign a different value

Time:10-29

Customers on the other side of the application of the database has a table, the original is only a field: name, now want to add a field: number, need to users to upgrade the program, increase the coding process has been completed in this field, now want to ask, after increase this field, how to give the number given different values respectively,

Thank you,

CodePudding user response:

In two steps, the first step: create a field, the second step: write data

CodePudding user response:

The do while not d.e of
The update...
D.m ovenext
Loop

CodePudding user response:

Your code there are a lot of hard coded in the database operation. So to change the database and program.

For example:
You. Field (" name ")=text1. The text or in turn assignment, this is bad code.
The database upgrade all need to change the code in the future.

Good practice is to not use hard code to the field and the corresponding control.
If you use the interface is the label + in the form of text, the label is used to display fields meaning, the text field is used to display content.
Default on the interface has a label1 (0) and text1 (0) :
 
.
FieldCount=you. Fields. The Count
Hei=Label1 (0). The Height + Text1 (0). The Height + 5
Lft fell=Label1 (0). The Left
.
If FieldCount & gt; 1 Then
For I=1 To FieldCount - 1
The Load Label1 (I)
The Load Text1 (I)
With Label1 (I)
. Move Lft fell, Hei * I + 5
The Visible=True
End With
With Text1 (I)
. Move Lft fell, Hei * I + Label1 (0). The Height + 5
The Visible=True
End With

Next
End the If
For I=0 To FieldCount - 1
Label1 (I). The Caption=FieldMemo (I)
Text1 (I). MaxLength=you. Fields (I). DefinedSize
Next


In this way, no matter how much you have a field, a list of all displayed. And set up good field length automatically, avoid excessive input.
You will notice that I finally USES a FieldMemo (I) array, which acquired from a database to store the information of each field "note".
Generally not recommended to do the field name in Chinese, and write the Chinese name in remark.
Access database can use adox objects to access field note, if SQL server can reference & gt;> This & lt;

It only contains the simple database part of the adaptive characteristics. There are data records to add, query, and so on.
Can do code correlation very, very low. Even case of can't avoid as far as possible the use of external configuration file, rather than directly into code.

Advantage is that such code, if just general field changes do not need to modify the program. Direct use database tools to change the database can take effect immediately.
  • Related