Ideas:
The original scheme:
We first design the Web form based on the fields and actual requirements of the database, then get the submitted dataset from the Web form, and then in the service segment, the committed dataset and the database field one by one correspond, then filter and process ...
The current scenario:
Generate a frame cache directly from the database, with each table's fields and their associated properties (type requirements, required, length, default values ...). ) is stored in the global array. When a form is submitted externally, the corresponding Dictionary object is generated from the corresponding global array, then the corresponding submission value is obtained based on the dictionary traversal of the fully mapped data table, thus replacing the tedious process of one by one correspondence and reading.
The implementation section is simplified to:
for i=0 to Ubound(KeysArray)-1
Key=KeysArray(i,0)
Item=Request(md5(Key))
objDict.Add Key,Item
next
In other words, this is the opposite of the traditional approach to the idea, this way to ensure that the data obtained must be the data required by the database, database requirements of the data type or must be empty data if there is an exception will inevitably error, and so on.
Finally, the statement that implements the form processing is simplified to, and all other operations are encapsulated in the class:
Call System_Initialize()
Dim objUser ''新建对象
Set objUser = new TUser
objUser.Table="Comm_User" ''指定数据表
If objUser.Creat Then ''建立表的Dictionary对象
objUser.ValidAndTransfer() ''获取数据、验证并转入最终的数据驱动层
objUser.Update() ''更新该表数据
End IF
Set objUser = nothing
Call System_Terminate()
Another aspect of this is the automatic generation of Web Forms from the cached data table framework, as required by the actual form, displayed on the client.
Traverse all user tables in the current database in SQL Server
SELECT Table_name
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_TYPE <> ''VIEW'')
TABLE_NAME: Table name;
Table_type: type of table;
See also: SQL Server online manual, T-SQL Reference, information Schema View.
PS: You can also implement related functions under Access [1]
To traverse the fields and properties of a specified table in SQL Server
SELECT Column_name,IS_NULLABLE,DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (TABLE_NAME = ''myTableName'')